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.

1038 lines
36 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1995 **
  4. //*********************************************************************
  5. //
  6. // OPENCPL.C - The is the heart of starting the "Internet Control Panel".
  7. // was DIALDLG.C
  8. // HISTORY:
  9. //
  10. // 4/5/95 jeremys Created.
  11. //
  12. // 6/22/96 t-gpease Moved everything that wasn't need (or global)
  13. // to start the control panel into separate,
  14. // managable pieces. This was part of the massive
  15. // (now defuncted) "dialdlg.c" that had just
  16. // about every property sheet written into it.
  17. // This completes the tearing apart of this
  18. // ("dialdlg.c") file. Whew!
  19. //
  20. //
  21. // [arthurbi]
  22. // WARNING - DO NOT ADD "static" variables to Dlg Procs!!!!
  23. // This code is designed to put up the same dlg in multi
  24. // threaded environments. Using globals that maintain
  25. // state is dangerous.
  26. //
  27. // State needs to be maintained in the hWin otherwise
  28. // it will generate bugs.
  29. //
  30. //
  31. // [arthurbi]
  32. // "REMOVED_ID", or DEAD Id: are based on PM decisions to no longer
  33. // have URLs Underlined. Left around because PMs may always
  34. // change their mind. In the meantime registry is always
  35. // there for people to change things.
  36. //
  37. #include "inetcplp.h"
  38. #include <inetcpl.h> // public header for INETCPL
  39. #include "apithk.h"
  40. #include <mluisupp.h>
  41. extern HMODULE hOLE32;
  42. typedef HRESULT (* PCOINIT) (LPVOID);
  43. extern PCOINIT pCoInitialize;
  44. extern BOOL _StartOLE32(); // initializes OLE
  45. #define MAX_NUM_OPTION_PAGES 24
  46. #ifndef UNIX
  47. #define NUM_OPTION_PAGES 6
  48. #else
  49. #ifdef UNIX_FEATURE_ALIAS
  50. #define NUM_OPTION_PAGES 8
  51. #else
  52. #define NUM_OPTION_PAGES 7
  53. #endif /* UNIX_FEATURE_ALIAS */
  54. #endif
  55. RESTRICT_FLAGS g_restrict = {0};
  56. //
  57. // Warning! LaunchConnectionDialog() below is sensitive to the order of
  58. // this list - it assumes connection tab is 4th in list. If you change it,
  59. // fix the function.
  60. //
  61. #ifdef UNIX
  62. extern INT_PTR CALLBACK DialupDlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
  63. #endif
  64. const struct {
  65. DWORD dwPageFlag;
  66. int idRes;
  67. DLGPROC pfnDlgProc;
  68. BOOL *pfDisabled;
  69. } c_PropInfo[] = {
  70. { INET_PAGE_GENERAL, IDD_GENERAL, General_DlgProc, &g_restrict.fGeneralTab },
  71. { INET_PAGE_SECURITY, IDD_SECURITY, SecurityDlgProc, &g_restrict.fSecurityTab },
  72. { INET_PAGE_PRIVACY, IDD_PRIVACY, PrivacyDlgProc, &g_restrict.fPrivacyTab },
  73. { INET_PAGE_CONTENT, IDD_CONTENT, ContentDlgProc, &g_restrict.fContentTab },
  74. #ifndef UNIX
  75. { INET_PAGE_CONNECTION, IDD_CONNECTION, ConnectionDlgProc, &g_restrict.fConnectionsTab },
  76. #else
  77. { INET_PAGE_CONNECTION, IDD_CONNECTION, DialupDlgProc, &g_restrict.fConnectionsTab },
  78. #endif
  79. { INET_PAGE_PROGRAMS, IDD_PROGRAMS, ProgramsDlgProc, &g_restrict.fProgramsTab },
  80. { INET_PAGE_ADVANCED, IDD_ADVANCED, AdvancedDlgProc, &g_restrict.fAdvancedTab },
  81. #ifdef UNIX
  82. { INET_PAGE_ASSOC, IDD_ASSOCIATIONS, AssocDlgProc, NULL },
  83. #ifdef UNIX_FEATURE_ALIAS
  84. { INET_PAGE_ALIAS, IDD_ALIASDLG, AliasDlgProc, NULL },
  85. #endif /* UNIX_FEATURE_ALIAS */
  86. #endif
  87. };
  88. #define IsPropPageEnabled(iPage) (c_PropInfo[iPage].pfDisabled==NULL || *c_PropInfo[iPage].pfDisabled==FALSE)
  89. #ifdef ARRAYSIZE
  90. #undef ARRAYSIZE
  91. #endif
  92. #define ARRAYSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
  93. TCHAR g_szCurrentURL[INTERNET_MAX_URL_LENGTH] = {0};
  94. WNDPROC pfnStaticWndProc = NULL;
  95. HWND g_hwndUpdate = NULL;
  96. BOOL g_fChangedMime = FALSE; // needed to indicate to MSHTML to
  97. // refresh the current page with a
  98. // new MIME and/or code page.
  99. BOOL g_fSecurityChanged = FALSE; // needed to indicate if a Active Security
  100. // has changed.
  101. HWND g_hwndPropSheet = NULL;
  102. PFNPROPSHEETCALLBACK g_PropSheetCallback2 = NULL;
  103. int CALLBACK PropSheetCallback(
  104. HWND hwndDlg,
  105. UINT uMsg,
  106. LPARAM lParam
  107. )
  108. {
  109. if (uMsg==PSCB_INITIALIZED)
  110. {
  111. ASSERT(hwndDlg);
  112. g_hwndPropSheet = hwndDlg;
  113. }
  114. #ifdef REPLACE_PROPSHEET_TEMPLATE
  115. return g_PropSheetCallback2 ? g_PropSheetCallback2(hwndDlg, uMsg, lParam)
  116. : PropSheetProc(hwndDlg, uMsg, lParam);
  117. #else
  118. return g_PropSheetCallback2 ? g_PropSheetCallback2(hwndDlg, uMsg, lParam)
  119. : 0;
  120. #endif
  121. }
  122. // begin ui restrictions stuff
  123. // key below used to be \software\microsoft\intenet explorer\restrictui
  124. //
  125. const TCHAR c_szKeyRestrict[] = REGSTR_PATH_INETCPL_RESTRICTIONS;
  126. const TCHAR c_szGeneralTab[] = REGSTR_VAL_INETCPL_GENERALTAB;
  127. const TCHAR c_szSecurityTab[] = REGSTR_VAL_INETCPL_SECURITYTAB;
  128. const TCHAR c_szContentTab[] = REGSTR_VAL_INETCPL_CONTENTTAB;
  129. const TCHAR c_szConnectionsTab[] = REGSTR_VAL_INETCPL_CONNECTIONSTAB;
  130. const TCHAR c_szProgramsTab[] = REGSTR_VAL_INETCPL_PROGRAMSTAB;
  131. const TCHAR c_szAdvancedTab[] = REGSTR_VAL_INETCPL_ADVANCEDTAB;
  132. const TCHAR c_szPrivacyTab[] = REGSTR_VAL_INETCPL_PRIVACYTAB;
  133. const TCHAR c_szColors[] = TEXT("Colors");
  134. const TCHAR c_szLinks[] = TEXT("Links");
  135. const TCHAR c_szFonts[] = TEXT("Fonts");
  136. const TCHAR c_szInternational[] = TEXT("Languages"); // used to be International
  137. const TCHAR c_szDialing[] = TEXT("Connection Settings"); // used to be Dialing
  138. const TCHAR c_szProxy[] = TEXT("Proxy");
  139. const TCHAR c_szPlaces[] = TEXT("HomePage"); // used to be Places
  140. const TCHAR c_szHistory[] = TEXT("History");
  141. const TCHAR c_szMailNews[] = TEXT("Messaging"); // used to be MailNews
  142. const TCHAR c_szResetWebSettings[] = TEXT("ResetWebSettings");
  143. const TCHAR c_szDefault[] = TEXT("Check_If_Default"); // used to be Default
  144. const TCHAR c_szRatings[] = TEXT("Ratings");
  145. const TCHAR c_szCertif[] = TEXT("Certificates"); // used to be Certif
  146. const TCHAR c_szCertifPers[] = TEXT("CertifPers");
  147. const TCHAR c_szCertifSite[] = TEXT("CertifSite");
  148. const TCHAR c_szCertifPub[] = TEXT("CertifPub");
  149. const TCHAR c_szCache[] = TEXT("Cache");
  150. const TCHAR c_szAutoConfig[] = TEXT("AutoConfig");
  151. const TCHAR c_szAccessibility[] = TEXT("Accessibility");
  152. const TCHAR c_szSecChangeSettings[] = TEXT("SecChangeSettings");
  153. const TCHAR c_szSecAddSites[] = TEXT("SecAddSites");
  154. const TCHAR c_szProfiles[] = TEXT("Profiles");
  155. const TCHAR c_szFormSuggest[] = TEXT("FormSuggest");
  156. const TCHAR c_szFormPasswords[] = TEXT("FormSuggest Passwords");
  157. #ifdef WALLET
  158. const TCHAR c_szWallet[] = TEXT("Wallet");
  159. #endif
  160. const TCHAR c_szConnectionWizard[] = TEXT("Connwiz Admin Lock");
  161. const TCHAR c_szCalContact[] = TEXT("CalendarContact"); // used to be CalContact
  162. const TCHAR c_szAdvanced[] = TEXT("Advanced");
  163. const TCHAR c_szSettings[] = TEXT("Settings");
  164. const TCHAR c_szPrivacySettings[] = TEXT("Privacy Settings");
  165. #if 0 // obsolete keys
  166. const TCHAR c_szMultimedia[] = TEXT("Multimedia");
  167. const TCHAR c_szToolbar[] = TEXT("Toolbar");
  168. const TCHAR c_szActiveX[] = TEXT("ActiveX");
  169. const TCHAR c_szActiveDownload[] = TEXT("ActiveDownload");
  170. const TCHAR c_szActiveControls[] = TEXT("ActiveControls");
  171. const TCHAR c_szActiveScript[] = TEXT("ActiveScript");
  172. const TCHAR c_szActiveJava[] = TEXT("ActiveJava");
  173. const TCHAR c_szActiveSafety[] = TEXT("ActiveSafety");
  174. const TCHAR c_szWarnings[] = TEXT("Warnings");
  175. const TCHAR c_szOther[] = TEXT("Other");
  176. const TCHAR c_szCrypto[] = TEXT("Crypto");
  177. const TCHAR c_szFileTypes[] = TEXT("FileTypes");
  178. #endif
  179. // end ui restrictions stuff
  180. #ifdef REPLACE_PROPSHEET_TEMPLATE
  181. // Used for modifying propsheet template
  182. const TCHAR c_szComctl[] = TEXT("comctl32.dll");
  183. #define DLG_PROPSHEET 1006 // Bad hack...assumes comctl's res id
  184. typedef struct
  185. {
  186. int inumLang;
  187. WORD wLang;
  188. } ENUMLANGDATA;
  189. //
  190. // EnumResLangProc
  191. //
  192. // purpose: a callback function for EnumResourceLanguages().
  193. // look into the type passed in and if it is RT_DIALOG
  194. // copy the lang of the first resource to our buffer
  195. // this also counts # of lang if more than one of them
  196. // are passed in
  197. //
  198. // IN: lparam: ENUMLANGDATA - defined at the top of this file
  199. //
  200. BOOL CALLBACK EnumResLangProc(HINSTANCE hinst, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIdLang, LPARAM lparam)
  201. {
  202. ENUMLANGDATA *pel = (ENUMLANGDATA *)lparam;
  203. ASSERT(pel);
  204. if (lpszType == RT_DIALOG)
  205. {
  206. if (pel->inumLang == 0)
  207. pel->wLang = wIdLang;
  208. pel->inumLang++;
  209. }
  210. return TRUE; // continue until we get all langs...
  211. }
  212. //
  213. // GetDialogLang
  214. //
  215. // purpose: fill out the ENUMLANGDATA (see top of this file) with the
  216. // # of available langs in the module passed in, and the langid
  217. // of what system enumerates first. i.e, the langid eq. to what
  218. // the module localized if the module is localized in single
  219. // language
  220. //
  221. // IN: hinstCpl - this is supposed to be a instance handle of inetcpl.
  222. // pel - a pointer to the buffer we fill out
  223. //
  224. // RESULT: TRUE - everything cool, continue with adjusting property sheet
  225. // FALSE - somethings wrong, abort adjusting property sheet.
  226. //
  227. BOOL GetDialogLang(HMODULE hinstCpl, ENUMLANGDATA *pel)
  228. {
  229. ASSERT(pel);
  230. OSVERSIONINFOA osvi;
  231. // Determine which version of NT or Windows we're running on
  232. osvi.dwOSVersionInfoSize = sizeof(osvi);
  233. GetVersionExA(&osvi);
  234. // Get the possible languages the template localized in.
  235. if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
  236. EnumResourceLanguages(hinstCpl, RT_DIALOG, MAKEINTRESOURCE(IDD_GENERAL), EnumResLangProc, (LPARAM)pel);
  237. else
  238. EnumResourceLanguagesA(hinstCpl, (LPSTR)RT_DIALOG, MAKEINTRESOURCEA(IDD_GENERAL), (ENUMRESLANGPROCA)EnumResLangProc, (LPARAM)pel);
  239. return TRUE;
  240. }
  241. //
  242. // PropSheetProc
  243. //
  244. // purpose: the callback function to modify resource template
  245. // in order to make DLG_PROPSHEET's lang mathed with ours.
  246. // there could be a general way but for now this is
  247. // an ugly hack from inetcpl.
  248. //
  249. //
  250. int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
  251. {
  252. LPVOID pTemplate = (LPVOID)lParam;
  253. LPVOID pTmpInLang = NULL;
  254. ENUMLANGDATA el = {0,0};
  255. HINSTANCE hComctl;
  256. HRSRC hrsrc;
  257. HGLOBAL hgmem;
  258. DWORD cbNewTmp;
  259. // Comm ctrl gives us a chance to recreate resource by this msg.
  260. if (uMsg==PSCB_PRECREATE && pTemplate)
  261. {
  262. // enumrate any possible language used in this cpl for dialogs
  263. if (!GetDialogLang(ghInstance, &el))
  264. return 0; // failed to get resouce name
  265. if (el.inumLang > 1)
  266. {
  267. // we've got multi-language templates
  268. // let comctl load the one that matches our thread langid.
  269. return 0;
  270. }
  271. if (GetSystemDefaultLangID() != el.wLang)
  272. {
  273. // Get comctl32's module handle
  274. hComctl = GetModuleHandle(c_szComctl);
  275. if (hComctl)
  276. {
  277. // this is a horrible hack because we assume DLG_PROPSHEET
  278. hrsrc = FindResourceExA(hComctl, (LPSTR)RT_DIALOG, MAKEINTRESOURCEA(DLG_PROPSHEET), el.wLang);
  279. if (hrsrc)
  280. {
  281. if (hgmem = LoadResource(hComctl, hrsrc))
  282. {
  283. pTmpInLang = LockResource(hgmem);
  284. }
  285. if (pTmpInLang)
  286. {
  287. cbNewTmp = SizeofResource(hComctl, hrsrc);
  288. hmemcpy(pTemplate, pTmpInLang, cbNewTmp);
  289. }
  290. if (hgmem && pTmpInLang)
  291. {
  292. UnlockResource(hgmem);
  293. return 1; // everything went ok.
  294. }
  295. }
  296. }
  297. }
  298. }
  299. return 0;
  300. }
  301. #endif // REPLACE_PROPSHEET_TEMPLATE
  302. void ResWinHelp( HWND hwnd, int ids, int id2, DWORD_PTR dwp)
  303. {
  304. TCHAR szSmallBuf[SMALL_BUF_LEN+1];
  305. SHWinHelpOnDemandWrap((HWND)hwnd, LoadSz(ids,szSmallBuf,sizeof(szSmallBuf)),
  306. id2, (DWORD_PTR)dwp);
  307. }
  308. /*******************************************************************
  309. NAME: _AddPropSheetPage
  310. SYNOPSIS: Adds a property sheet page to a property sheet
  311. header's array of property sheet pages.
  312. ********************************************************************/
  313. BOOL CALLBACK _AddPropSheetPage(HPROPSHEETPAGE hpage, LPARAM lParam)
  314. {
  315. BOOL bResult;
  316. LPPROPSHEETHEADER ppsh = (LPPROPSHEETHEADER)lParam;
  317. bResult = (ppsh->nPages < MAX_NUM_OPTION_PAGES);
  318. if (bResult)
  319. ppsh->phpage[ppsh->nPages++] = hpage;
  320. return(bResult);
  321. }
  322. // hunts down all windows and notifies them that they should update themselves
  323. // a-msadek; Use SendMessage instead of PostMessage to work around a syncronization problem causing the system to
  324. // hang when changing security settings
  325. void UpdateAllWindows()
  326. {
  327. SendMessage(g_hwndUpdate, INM_UPDATE, 0, 0);
  328. // PostMessage(g_hwndUpdate, INM_UPDATE, 0, 0);
  329. }
  330. // walk the window list and post a message to it telling the windows to
  331. // update (borrowed from MSHTML and slightly modified)
  332. void WINAPI MSHTMLNotifyAllRefresh()
  333. {
  334. TCHAR szClassName[32];
  335. TCHAR *Hidden_achClassName;
  336. HWND hwnd = GetTopWindow(GetDesktopWindow());
  337. //
  338. // FEATURE: These should be gotten from some place that is public
  339. // to both MSHTML and INETCPL.
  340. //
  341. Hidden_achClassName = TEXT("Internet Explorer_Hidden");
  342. #define WM_DO_UPDATEALL WM_USER + 338
  343. while (hwnd) {
  344. GetClassName(hwnd, szClassName, ARRAYSIZE(szClassName));
  345. // is this our hidden window?
  346. if (!StrCmpI(szClassName, Hidden_achClassName))
  347. {
  348. // yes... post it a message..
  349. PostMessage(hwnd, WM_DO_UPDATEALL, 0, g_fSecurityChanged );
  350. }
  351. hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
  352. }
  353. //
  354. // Notify top level windows that registry changed.
  355. // Defview monitors this message to update the listview
  356. // font underline settings on the fly.
  357. //
  358. SendBroadcastMessage(WM_WININICHANGE, SPI_GETICONTITLELOGFONT, (LPARAM)REGSTR_PATH_IEXPLORER);
  359. g_fSecurityChanged = FALSE;
  360. }
  361. // this window's sole purpose is to collect all the posted messages
  362. // saying that we should update everything and collapse it down so that
  363. // we only do it once
  364. LRESULT WINAPI UpdateWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  365. {
  366. MSG msg;
  367. switch(uMsg) {
  368. case WM_DESTROY:
  369. g_hwndUpdate = NULL;
  370. // update everything as needed.. remove all messages
  371. if (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) {
  372. MSHTMLNotifyAllRefresh();
  373. SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnStaticWndProc);
  374. }
  375. // since EXPLORER.EXE can hang on to us for a long while
  376. // we should bail as many of these as we possibly can.
  377. if (g_hinstWinInet)
  378. {
  379. FreeLibrary(g_hinstWinInet);
  380. g_hinstWinInet = NULL;
  381. }
  382. if (g_hinstRatings)
  383. {
  384. FreeLibrary(g_hinstRatings);
  385. g_hinstRatings = NULL;
  386. }
  387. if (g_hinstUrlMon)
  388. {
  389. FreeLibrary(g_hinstUrlMon);
  390. g_hinstUrlMon = NULL;
  391. }
  392. if (g_hinstMSHTML)
  393. {
  394. FreeLibrary(g_hinstMSHTML);
  395. g_hinstMSHTML = NULL;
  396. }
  397. if (hOLE32)
  398. {
  399. FreeLibrary(hOLE32);
  400. hOLE32 = NULL;
  401. }
  402. if (g_hinstShdocvw)
  403. {
  404. FreeLibrary(g_hinstShdocvw);
  405. g_hinstShdocvw = NULL;
  406. }
  407. if (g_hinstCrypt32)
  408. {
  409. FreeLibrary(g_hinstCrypt32);
  410. g_hinstCrypt32 = NULL;
  411. }
  412. break;
  413. case INM_UPDATE:
  414. // remove any other posted messages of this type
  415. while( PeekMessage(&msg, hwnd, INM_UPDATE, INM_UPDATE, PM_REMOVE))
  416. {
  417. }
  418. MSHTMLNotifyAllRefresh();
  419. break;
  420. default:
  421. return CallWindowProc(pfnStaticWndProc, hwnd, uMsg, wParam, lParam);
  422. }
  423. return 0L;
  424. }
  425. // this creates our private message window that we use to collapse notifies
  426. // of updates
  427. void CreatePrivateWindow(HWND hDlg)
  428. {
  429. // Don't allow creation of more than one Private Window per Instance
  430. if(g_hwndUpdate) {
  431. return;
  432. }
  433. g_hwndUpdate = CreateWindow(TEXT("static"), NULL, WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  434. NULL, NULL, ghInstance, NULL);
  435. if (g_hwndUpdate) {
  436. // subclass it
  437. pfnStaticWndProc = (WNDPROC) GetWindowLongPtr(g_hwndUpdate, GWLP_WNDPROC);
  438. SetWindowLongPtr(g_hwndUpdate, GWLP_WNDPROC, (LONG_PTR)UpdateWndProc);
  439. }
  440. }
  441. BOOL IsRestricted( HKEY hkey, const TCHAR * pszValue )
  442. {
  443. LONG lResult;
  444. DWORD lSize;
  445. DWORD lValue;
  446. lValue = 0; // clear it
  447. lSize = sizeof(lValue);
  448. lResult = RegQueryValueEx( hkey, pszValue, NULL, NULL, (LPBYTE)&lValue, &lSize );
  449. if( ERROR_SUCCESS != lResult )
  450. return FALSE;
  451. return (0 != lValue);
  452. }
  453. void GetRestrictFlags( RESTRICT_FLAGS *pRestrict )
  454. {
  455. LONG lResult;
  456. HKEY hkey;
  457. // key is wrong!
  458. lResult = RegOpenKeyEx( HKEY_CURRENT_USER, c_szKeyRestrict, (DWORD)0, KEY_READ, &hkey );
  459. if( ERROR_SUCCESS != lResult )
  460. return;
  461. #if 0
  462. pRestrict->fMultimedia = IsRestricted( hkey, c_szMultimedia );
  463. pRestrict->fToolbar = IsRestricted( hkey, c_szToolbar );
  464. pRestrict->fFileTypes = IsRestricted( hkey, c_szFileTypes );
  465. pRestrict->fActiveX = IsRestricted( hkey, c_szActiveX );
  466. pRestrict->fActiveDownload= IsRestricted( hkey, c_szActiveDownload );
  467. pRestrict->fActiveControls= IsRestricted( hkey, c_szActiveControls );
  468. pRestrict->fActiveScript = IsRestricted( hkey, c_szActiveScript );
  469. pRestrict->fActiveJava = IsRestricted( hkey, c_szActiveJava );
  470. pRestrict->fActiveSafety = IsRestricted( hkey, c_szActiveSafety );
  471. pRestrict->fWarnings = IsRestricted( hkey, c_szWarnings );
  472. pRestrict->fOther = IsRestricted( hkey, c_szOther );
  473. pRestrict->fCrypto = IsRestricted( hkey, c_szCrypto );
  474. #endif
  475. pRestrict->fGeneralTab = IsRestricted( hkey, c_szGeneralTab );
  476. pRestrict->fSecurityTab = IsRestricted( hkey, c_szSecurityTab );
  477. pRestrict->fContentTab = IsRestricted( hkey, c_szContentTab );
  478. pRestrict->fConnectionsTab= IsRestricted( hkey, c_szConnectionsTab );
  479. pRestrict->fProgramsTab = IsRestricted( hkey, c_szProgramsTab );
  480. pRestrict->fAdvancedTab = IsRestricted( hkey, c_szAdvancedTab );
  481. pRestrict->fPrivacyTab = IsRestricted( hkey, c_szPrivacyTab );
  482. pRestrict->fColors = IsRestricted( hkey, c_szColors );
  483. pRestrict->fLinks = IsRestricted( hkey, c_szLinks );
  484. pRestrict->fFonts = IsRestricted( hkey, c_szFonts );
  485. pRestrict->fInternational = IsRestricted( hkey, c_szInternational );
  486. pRestrict->fDialing = IsRestricted( hkey, c_szDialing );
  487. pRestrict->fProxy = IsRestricted( hkey, c_szProxy );
  488. pRestrict->fPlaces = IsRestricted( hkey, c_szPlaces );
  489. pRestrict->fHistory = IsRestricted( hkey, c_szHistory );
  490. pRestrict->fMailNews = IsRestricted( hkey, c_szMailNews );
  491. pRestrict->fRatings = IsRestricted( hkey, c_szRatings );
  492. pRestrict->fCertif = IsRestricted( hkey, c_szCertif );
  493. pRestrict->fCertifPers = IsRestricted( hkey, c_szCertifPers );
  494. pRestrict->fCertifSite = IsRestricted( hkey, c_szCertifSite );
  495. pRestrict->fCertifPub = IsRestricted( hkey, c_szCertifPub );
  496. pRestrict->fCache = IsRestricted( hkey, c_szCache );
  497. pRestrict->fAutoConfig = IsRestricted( hkey, c_szAutoConfig );
  498. pRestrict->fAccessibility = IsRestricted( hkey, c_szAccessibility );
  499. pRestrict->fSecChangeSettings = IsRestricted( hkey, c_szSecChangeSettings );
  500. pRestrict->fSecAddSites = IsRestricted( hkey, c_szSecAddSites );
  501. pRestrict->fProfiles = IsRestricted( hkey, c_szProfiles );
  502. pRestrict->fFormSuggest = IsRestricted( hkey, c_szFormSuggest );
  503. pRestrict->fFormPasswords = IsRestricted( hkey, c_szFormPasswords );
  504. #ifdef WALLET
  505. pRestrict->fWallet = IsRestricted( hkey, c_szWallet );
  506. #endif
  507. pRestrict->fConnectionWizard = IsRestricted( hkey, c_szConnectionWizard );
  508. pRestrict->fCalContact = IsRestricted( hkey, c_szCalContact );
  509. pRestrict->fAdvanced = IsRestricted( hkey, c_szAdvanced );
  510. pRestrict->fCacheReadOnly = IsRestricted( hkey, c_szSettings );
  511. pRestrict->fResetWebSettings = IsRestricted( hkey, c_szResetWebSettings );
  512. pRestrict->fDefault = IsRestricted( hkey, c_szDefault );
  513. pRestrict->fPrivacySettings = IsRestricted( hkey, c_szPrivacySettings );
  514. RegCloseKey( hkey );
  515. }
  516. // this sets up any globals that need to be init'ed before the prop sheets come up
  517. void PreInitPropSheets(HWND hDlg)
  518. {
  519. INITCOMMONCONTROLSEX icex;
  520. //
  521. // initialize the ieak restrictions data
  522. //
  523. GetRestrictFlags(&g_restrict);
  524. icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  525. icex.dwICC = ICC_USEREX_CLASSES|ICC_NATIVEFNTCTL_CLASS;
  526. InitCommonControlsEx(&icex);
  527. CreatePrivateWindow(hDlg);
  528. }
  529. /*******************************************************************
  530. NAME: AddInternetPropertySheetsEx
  531. SYNOPSIS: Adds the Internet property sheets through a provided
  532. callback function. Allows caller to specify common
  533. parent reference count pointer and common callback
  534. function for those property sheets.
  535. ********************************************************************/
  536. STDAPI AddInternetPropertySheetsEx(LPFNADDPROPSHEETPAGE pfnAddPage,
  537. LPARAM lparam, PUINT pucRefCount,
  538. LPFNPSPCALLBACK pfnCallback,
  539. LPIEPROPPAGEINFO piepi)
  540. {
  541. HRESULT hr = S_OK;
  542. PROPSHEETPAGE* ppsPage;
  543. int nPageIndex;
  544. LPPROPSHEETHEADER ppsh = (LPPROPSHEETHEADER)lparam;
  545. PreInitPropSheets(NULL);
  546. // if REPLACE_PROPSHEET_TEMPLATE is defined, then this
  547. // callback will call another proc
  548. // this is to modify a resource template so we can use
  549. // the resource in matched language for property sheet
  550. g_PropSheetCallback2 = NULL;
  551. if (ppsh)
  552. {
  553. if (!(ppsh->dwFlags & PSH_USECALLBACK))
  554. {
  555. ppsh->dwFlags |= PSH_USECALLBACK;
  556. }
  557. else
  558. {
  559. g_PropSheetCallback2 = ppsh->pfnCallback;
  560. }
  561. ppsh->pfnCallback = PropSheetCallback;
  562. }
  563. if (piepi->pszCurrentURL)
  564. {
  565. #ifdef UNICODE
  566. SHAnsiToUnicode(piepi->pszCurrentURL, g_szCurrentURL, ARRAYSIZE(g_szCurrentURL));
  567. #else
  568. StrCpyN(g_szCurrentURL, piepi->pszCurrentURL, ARRAYSIZE(g_szCurrentURL));
  569. #endif
  570. }
  571. else
  572. g_szCurrentURL[0] = 0;
  573. // fill out common data property sheet page struct
  574. hr = E_OUTOFMEMORY;
  575. ppsPage = Whistler_CreatePropSheetPageStruct(MLGetHinst()); // Get the right version
  576. if (ppsPage)
  577. {
  578. if (pucRefCount)
  579. {
  580. ppsPage->pcRefParent = pucRefCount;
  581. ppsPage->dwFlags |= PSP_USEREFPARENT;
  582. }
  583. if (pfnCallback)
  584. {
  585. ppsPage->pfnCallback = pfnCallback;
  586. ppsPage->dwFlags |= PSP_USECALLBACK;
  587. }
  588. // if old IE30 users specify the old security page, then we'll show the new security page and the content page
  589. if (piepi->dwFlags & INET_PAGE_SECURITY_OLD)
  590. piepi->dwFlags |= INET_PAGE_SECURITY | INET_PAGE_CONTENT;
  591. // create a property sheet page for each page
  592. for (nPageIndex = 0; nPageIndex < ARRAYSIZE(c_PropInfo); nPageIndex++)
  593. {
  594. if (c_PropInfo[nPageIndex].dwPageFlag & piepi->dwFlags &&
  595. IsPropPageEnabled(nPageIndex))
  596. {
  597. HPROPSHEETPAGE hpage;
  598. ppsPage->pfnDlgProc = c_PropInfo[nPageIndex].pfnDlgProc;
  599. ppsPage->pszTemplate = MAKEINTRESOURCE(c_PropInfo[nPageIndex].idRes);
  600. // set a pointer to the PAGEINFO struct as the private data for this page
  601. ppsPage->lParam = (LPARAM)nPageIndex;
  602. hpage = CreatePropertySheetPage((LPCPROPSHEETPAGE)ppsPage);
  603. if (hpage)
  604. {
  605. if (pfnAddPage(hpage, lparam))
  606. hr = S_OK;
  607. else
  608. {
  609. DestroyPropertySheetPage(hpage);
  610. hr = E_FAIL;
  611. }
  612. }
  613. else
  614. hr = E_OUTOFMEMORY;
  615. if (hr != S_OK)
  616. break;
  617. }
  618. }
  619. LocalFree(ppsPage);
  620. }
  621. // this must be done after the pre-init prop sheet which has first
  622. // crack at initializing g_restrict
  623. if (piepi->cbSize == sizeof(IEPROPPAGEINFO))
  624. {
  625. //
  626. // blast in the new settings
  627. //
  628. if (piepi->dwRestrictMask & (R_MULTIMEDIA | R_WARNINGS | R_CRYPTOGRAPHY | R_ADVANCED))
  629. g_restrict.fAdvanced = (piepi->dwRestrictFlags & (R_MULTIMEDIA | R_WARNINGS | R_CRYPTOGRAPHY | R_ADVANCED));
  630. if (piepi->dwRestrictMask & R_DIALING)
  631. g_restrict.fDialing = (piepi->dwRestrictFlags & R_DIALING);
  632. if (piepi->dwRestrictMask & R_PROXYSERVER)
  633. g_restrict.fProxy = (piepi->dwRestrictFlags & R_PROXYSERVER);
  634. if (piepi->dwRestrictMask & R_CUSTOMIZE)
  635. g_restrict.fPlaces = (piepi->dwRestrictFlags & R_CUSTOMIZE);
  636. if (piepi->dwRestrictMask & R_HISTORY)
  637. g_restrict.fHistory = (piepi->dwRestrictFlags & R_HISTORY);
  638. if (piepi->dwRestrictMask & R_MAILANDNEWS)
  639. g_restrict.fMailNews = (piepi->dwRestrictFlags & R_MAILANDNEWS);
  640. if (piepi->dwRestrictMask & R_CHECKBROWSER )
  641. g_restrict.fDefault = (piepi->dwRestrictFlags & R_CHECKBROWSER);
  642. if (piepi->dwRestrictMask & R_COLORS)
  643. g_restrict.fColors = (piepi->dwRestrictFlags & R_COLORS);
  644. if (piepi->dwRestrictMask & R_LINKS)
  645. g_restrict.fLinks = (piepi->dwRestrictFlags & R_LINKS);
  646. if (piepi->dwRestrictMask & R_FONTS)
  647. g_restrict.fFonts = (piepi->dwRestrictFlags & R_FONTS);
  648. if (piepi->dwRestrictMask & R_RATINGS)
  649. g_restrict.fRatings = (piepi->dwRestrictFlags & R_RATINGS);
  650. if (piepi->dwRestrictMask & R_CERTIFICATES) {
  651. g_restrict.fCertif = (piepi->dwRestrictFlags & R_CERTIFICATES);
  652. g_restrict.fCertifPers = g_restrict.fCertif;
  653. g_restrict.fCertifSite = g_restrict.fCertif;
  654. g_restrict.fCertifPub = g_restrict.fCertif;
  655. }
  656. if (piepi->dwRestrictMask & (R_ACTIVECONTENT | R_SECURITY_CHANGE_SETTINGS))
  657. g_restrict.fSecChangeSettings = (piepi->dwRestrictFlags & (R_ACTIVECONTENT | R_SECURITY_CHANGE_SETTINGS ));
  658. if (piepi->dwRestrictMask & (R_ACTIVECONTENT | R_SECURITY_CHANGE_SITES))
  659. g_restrict.fSecAddSites = (piepi->dwRestrictFlags & (R_ACTIVECONTENT | R_SECURITY_CHANGE_SITES));
  660. if (piepi->dwRestrictMask & R_CACHE)
  661. g_restrict.fCache = (piepi->dwRestrictFlags & R_CACHE);
  662. if (piepi->dwRestrictMask & R_LANGUAGES )
  663. g_restrict.fInternational = (piepi->dwRestrictFlags & R_LANGUAGES );
  664. if (piepi->dwRestrictMask & R_ACCESSIBILITY )
  665. g_restrict.fAccessibility = (piepi->dwRestrictFlags & R_ACCESSIBILITY);
  666. if (piepi->dwRestrictMask & R_PROFILES)
  667. {
  668. g_restrict.fFormSuggest= // piggyback on "profile assistant" restriction
  669. g_restrict.fProfiles = (piepi->dwRestrictFlags & R_PROFILES);
  670. }
  671. #ifdef WALLET
  672. if (piepi->dwRestrictMask & R_WALLET)
  673. g_restrict.fWallet = (piepi->dwRestrictFlags & R_WALLET);
  674. #endif
  675. if (piepi->dwRestrictMask & R_CONNECTION_WIZARD)
  676. g_restrict.fConnectionWizard = (piepi->dwRestrictFlags & R_CONNECTION_WIZARD);
  677. if (piepi->dwRestrictMask & R_AUTOCONFIG)
  678. g_restrict.fAutoConfig = (piepi->dwRestrictFlags & R_AUTOCONFIG);
  679. if (piepi->dwRestrictMask & R_CAL_CONTACT)
  680. g_restrict.fCalContact = (piepi->dwRestrictFlags & R_CAL_CONTACT);
  681. if (piepi->dwRestrictMask & R_ADVANCED)
  682. g_restrict.fAdvanced = (piepi->dwRestrictFlags & R_ADVANCED);
  683. }
  684. return(hr);
  685. }
  686. STDAPI AddInternetPropertySheets(LPFNADDPROPSHEETPAGE pfnAddPage,
  687. LPARAM lparam, PUINT pucRefCount,
  688. LPFNPSPCALLBACK pfnCallback)
  689. {
  690. IEPROPPAGEINFO iepi;
  691. iepi.cbSize = sizeof(iepi);
  692. iepi.pszCurrentURL = NULL;
  693. // if not loaded, try to load
  694. if (!g_hinstMSHTML)
  695. g_hinstMSHTML = LoadLibrary(c_tszMSHTMLDLL);
  696. // if MSHTML found, then do the standard INETCPL
  697. if (g_hinstMSHTML)
  698. {
  699. iepi.dwFlags = (DWORD)-1;
  700. iepi.dwRestrictFlags = (DWORD)0;
  701. iepi.dwRestrictMask = (DWORD)0;
  702. }
  703. else
  704. {
  705. // adjust these flags for the "special" inetcpl for the office guys.
  706. iepi.dwFlags = (DWORD)
  707. INET_PAGE_CONNECTION | INET_PAGE_PROGRAMS
  708. | INET_PAGE_SECURITY | INET_PAGE_ADVANCED;
  709. iepi.dwRestrictFlags = (DWORD)
  710. R_HISTORY | R_OTHER | R_CHECKBROWSER;
  711. iepi.dwRestrictMask = (DWORD)
  712. R_HISTORY | R_OTHER | R_CHECKBROWSER;
  713. }
  714. return AddInternetPropertySheetsEx(pfnAddPage, lparam, pucRefCount, pfnCallback, &iepi);
  715. }
  716. void DestroyPropertySheets(LPPROPSHEETHEADER ppsHeader)
  717. {
  718. UINT nFreeIndex;
  719. for (nFreeIndex = 0; nFreeIndex < ppsHeader->nPages; nFreeIndex++)
  720. DestroyPropertySheetPage(ppsHeader->phpage[nFreeIndex]);
  721. }
  722. /*******************************************************************
  723. NAME: LaunchInternetControlPanel
  724. SYNOPSIS: Runs the Internet control panel.
  725. WARNING: This needs to be as bare bones as possible.
  726. the pages are also added in from the internet (iShellFolder)
  727. property page extension which means it doesn't come into this
  728. code. if you do any initialization/destruction here,
  729. it won't get called on all cases.
  730. ********************************************************************/
  731. STDAPI_(BOOL) LaunchInternetControlPanelAtPage(HWND hDlg, UINT nStartPage)
  732. {
  733. HPROPSHEETPAGE hOptPage[ MAX_NUM_OPTION_PAGES ]; // array to hold handles to pages
  734. PROPSHEETHEADER psHeader;
  735. BOOL fRet;
  736. HPSXA hpsxa;
  737. HRESULT hrOle = SHCoInitialize();
  738. // OLE Needs to be initialized for AutoComplete and the FTP URL association.
  739. // Don't need to test for nStartPage < 0 since UINTs are never negative
  740. if (nStartPage != DEFAULT_CPL_PAGE &&
  741. (nStartPage >= ARRAYSIZE(c_PropInfo)))
  742. {
  743. nStartPage = DEFAULT_CPL_PAGE;
  744. }
  745. //
  746. // initialize the ieak restrictions data
  747. //
  748. GetRestrictFlags(&g_restrict);
  749. //
  750. // The caller will pass DEFAULT_CPL_PAGE for nStartPage when it doesn't care
  751. // which tab should be displayed first. In this case, we just
  752. // display the first tab that's not disabled via IEAK
  753. //
  754. if (DEFAULT_CPL_PAGE == nStartPage)
  755. {
  756. int iPage;
  757. for (iPage=0; iPage<ARRAYSIZE(c_PropInfo); iPage++)
  758. {
  759. if (IsPropPageEnabled(iPage))
  760. break;
  761. }
  762. //
  763. // If the ieak has disabled ALL the pages, then we don't
  764. // can't display the inetcpl. Show a message.
  765. //
  766. if (iPage == ARRAYSIZE(c_PropInfo))
  767. {
  768. MLShellMessageBox(
  769. hDlg,
  770. MAKEINTRESOURCEW(IDS_RESTRICTED_MESSAGE),
  771. MAKEINTRESOURCEW(IDS_RESTRICTED_TITLE),
  772. MB_OK);
  773. return FALSE;
  774. }
  775. else
  776. {
  777. nStartPage = 0;
  778. }
  779. }
  780. //
  781. // This means the caller has requested that a specific start
  782. // page for the propsheet
  783. //
  784. else
  785. {
  786. int iPage;
  787. //
  788. // If the caller has requested a specific page, and that
  789. // page is disabled due to IEAK restrictions, then don't
  790. // display the inetcpl at all. Show a messagebox.
  791. //
  792. if (!IsPropPageEnabled(nStartPage))
  793. {
  794. MLShellMessageBox(
  795. hDlg,
  796. MAKEINTRESOURCE(IDS_RESTRICTED_MESSAGE),
  797. MAKEINTRESOURCE(IDS_RESTRICTED_TITLE),
  798. MB_OK);
  799. return FALSE;
  800. }
  801. //
  802. // Due to IEAK restrictions, there may be one or more pages
  803. // before nStartPage that are actually missing. We need to
  804. // decrement nStartPage to take that into account.
  805. //
  806. for (iPage=nStartPage-1; iPage>=0; iPage--)
  807. if (!IsPropPageEnabled(iPage))
  808. nStartPage--;
  809. }
  810. memset(&psHeader,0,sizeof(psHeader));
  811. psHeader.dwSize = sizeof(psHeader);
  812. psHeader.dwFlags = PSH_PROPTITLE;
  813. psHeader.hwndParent = hDlg;
  814. psHeader.hInstance = MLGetHinst();
  815. psHeader.nPages = 0;
  816. psHeader.nStartPage = nStartPage;
  817. psHeader.phpage = hOptPage;
  818. psHeader.pszCaption = MAKEINTRESOURCE(IDS_INTERNET_LOC);
  819. if (AddInternetPropertySheets(&_AddPropSheetPage, (LPARAM)&psHeader, NULL,
  820. NULL) == S_OK)
  821. {
  822. // add any extra pages from hooks in the registry
  823. if( ( hpsxa = SHCreatePropSheetExtArray( HKEY_LOCAL_MACHINE,
  824. REGSTR_PATH_INETCPL_PS_EXTENTIONS, MAX_NUM_OPTION_PAGES - NUM_OPTION_PAGES ) ) != NULL )
  825. {
  826. SHAddFromPropSheetExtArray( hpsxa, _AddPropSheetPage, (LPARAM)&psHeader );
  827. }
  828. // bring it up
  829. PropertySheet( &psHeader );
  830. // free the hooks if we loaded them
  831. if ( hpsxa )
  832. SHDestroyPropSheetExtArray( hpsxa );
  833. fRet = TRUE;
  834. }
  835. else
  836. {
  837. DestroyPropertySheets(&psHeader);
  838. MsgBox(NULL, IDS_ERROutOfMemory, MB_ICONEXCLAMATION, MB_OK);
  839. fRet = FALSE;
  840. }
  841. SHCoUninitialize(hrOle);
  842. return fRet;
  843. }
  844. STDAPI_(BOOL) LaunchInternetControlPanel(HWND hDlg)
  845. {
  846. return LaunchInternetControlPanelAtPage(hDlg, DEFAULT_CPL_PAGE);
  847. }
  848. STDAPI_(BOOL) LaunchConnectionDialog(HWND hDlg)
  849. {
  850. ASSERT(INET_PAGE_CONNECTION == c_PropInfo[4].dwPageFlag);
  851. return LaunchInternetControlPanelAtPage(hDlg, 4);
  852. }
  853. STDAPI_(BOOL) LaunchPrivacyDialog(HWND hDlg)
  854. {
  855. ASSERT(INET_PAGE_PRIVACY == c_PropInfo[2].dwPageFlag);
  856. return LaunchInternetControlPanelAtPage(hDlg, 2);
  857. }
  858. BOOL IsCompatModeProcess()
  859. {
  860. if (GetModuleHandle(TEXT("IE4.EXE")) || GetModuleHandle(TEXT("IESQRL.EXE")))
  861. {
  862. // If we are running in compat mode, exit because we don't want users
  863. // mucking with control panel from here.
  864. WinExec("control.exe", SW_NORMAL);
  865. return TRUE;
  866. }
  867. return FALSE;
  868. }