2 * shpolicy.c - Data for shell/system policies.
4 * Created 1999 by Ian Schmidt <ischmidt@cfl.rr.com>
6 * Some of these policies can be tweaked via the System Policy
7 * Editor which came with the Win95 Migration Guide, although
8 * there doesn't appear to be an updated Win98 version that
9 * would handle the many new policies introduced since then.
10 * You could easily write one with the information in
13 * Up to date as of SHELL32 v4.72 (Win98, Win95 with MSIE 5)
23 #include "undocshell.h"
24 #include "wine/winuser16.h"
26 #include "debugtools.h"
28 DEFAULT_DEBUG_CHANNEL(shell);
30 #define SHELL_MAX_POLICIES 57
32 #define SHELL_NO_POLICY 0xffffffff
34 typedef struct tagPOLICYDAT
36 DWORD polflags; /* flags value passed to SHRestricted */
37 LPSTR appstr; /* application str such as "Explorer" */
38 LPSTR keystr; /* name of the actual registry key / policy */
39 DWORD cache; /* cached value or 0xffffffff for invalid */
40 } POLICYDATA, *LPPOLICYDATA;
42 //extern POLICYDATA sh32_policy_table[SHELL_MAX_POLICIES];
44 /* application strings */
46 static char strExplorer[] = {"Explorer"};
47 static char strActiveDesk[] = {"ActiveDesktop"};
48 static char strWinOldApp[] = {"WinOldApp"};
52 static char strNoFileURL[] = {"NoFileUrl"};
53 static char strNoFolderOptions[] = {"NoFolderOptions"};
54 static char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
55 static char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
56 static char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
57 static char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
58 static char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
59 static char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
60 static char strNoResolveTrk[] = {"NoResolveTrack"};
61 static char strNoResolveSearch[] = {"NoResolveSearch"};
62 static char strNoEditComponent[] = {"NoEditingComponents"};
63 static char strNoMovingBand[] = {"NoMovingBands"};
64 static char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
65 static char strNoCloseComponent[] = {"NoClosingComponents"};
66 static char strNoDelComponent[] = {"NoDeletingComponents"};
67 static char strNoAddComponent[] = {"NoAddingComponents"};
68 static char strNoComponent[] = {"NoComponents"};
69 static char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
70 static char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
71 static char strNoCustomWebView[] = {"NoCustomizeWebView"};
72 static char strClassicShell[] = {"ClassicShell"};
73 static char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
74 static char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
75 static char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
76 static char strNoActiveDesktop[] = {"NoActiveDesktop"};
77 static char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
78 static char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
79 static char strNoInetIcon[] = {"NoInternetIcon"};
80 static char strNoStngsWizard[] = {"NoSettingsWizards"};
81 static char strNoLogoff[] = {"NoLogoff"};
82 static char strNoNetConDis[] = {"NoNetConnectDisconnect"};
83 static char strNoContextMenu[] = {"NoViewContextMenu"};
84 static char strNoTryContextMenu[] = {"NoTrayContextMenu"};
85 static char strNoWebMenu[] = {"NoWebMenu"};
86 static char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
87 static char strNoCommonGroups[] = {"NoCommonGroups"};
88 static char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
89 static char strNoRealMode[] = {"NoRealMode"};
90 static char strMyDocsOnNet[] = {"MyDocsOnNet"};
91 static char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
92 static char strNoAddPrinters[] = {"NoAddPrinter"};
93 static char strNoDeletePrinters[] = {"NoDeletePrinter"};
94 static char strNoPrintTab[] = {"NoPrinterTabs"};
95 static char strRestrictRun[] = {"RestrictRun"};
96 static char strNoStartBanner[] = {"NoStartBanner"};
97 static char strNoNetworkNeighborhood[] = {"NoNetHood"};
98 static char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
99 static char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
100 static char strNoDrives[] = {"NoDrives"};
101 static char strNoFind[] = {"NoFind"};
102 static char strNoDesktop[] = {"NoDesktop"};
103 static char strNoSetTaskBar[] = {"NoSetTaskbar"};
104 static char strNoSetFld[] = {"NoSetFolders"};
105 static char strNoFileMenu[] = {"NoFileMenu"};
106 static char strNoSavSetng[] = {"NoSaveSettings"};
107 static char strNoClose[] = {"NoClose"};
108 static char strNoRun[] = {"NoRun"};
110 /* policy data array */
112 POLICYDATA sh32_policy_table[] =
183 strNoNetworkNeighborhood,
219 strNoStartMenuSubfolder,
237 strEnforceShlExtSecurity,
243 strLnkResolveIgnoreLnkInfo,
297 strNoRecentDocHistory,
315 strNoActiveDesktopChanges,
351 strNoChangeWallpaper,
423 strNoForgetSoftwareUpdate,
429 strNoSetActiveDesktop,
441 strNoChangeStartMenu,
458 /*************************************************************************
459 * SHRestricted [SHELL32.100]
461 * walks through policy table, queries <app> key, <type> value, returns
462 * queried (DWORD) value, and caches it between called to SHInitRestricted
463 * to prevent unnecessary registry access.
466 * exported by ordinal
469 * MS System Policy Editor
470 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
471 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
473 DWORD WINAPI SHRestricted (DWORD pol) {
476 DWORD retval, polidx, i, datsize = 4;
478 TRACE("(%08lx)\n",pol);
482 /* scan to see if we know this policy ID */
483 for (i = 0; i < SHELL_MAX_POLICIES; i++)
485 if (pol == sh32_policy_table[i].polflags)
494 /* we don't know this policy, return 0 */
495 TRACE("unknown policy: (%08lx)\n", pol);
499 /* we have a known policy */
500 strcpy(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
501 strcat(regstr, sh32_policy_table[polidx].appstr);
503 /* first check if this policy has been cached, return it if so */
504 if (sh32_policy_table[polidx].cache != SHELL_NO_POLICY)
506 return sh32_policy_table[polidx].cache;
509 /* return 0 and don't set the cache if any registry errors occur */
511 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
513 if (RegQueryValueExA(xhkey, sh32_policy_table[polidx].keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
515 sh32_policy_table[polidx].cache = retval;
524 /*************************************************************************
525 * SHInitRestricted [SHELL32.244]
527 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
528 * Inits the policy cache used by SHRestricted to avoid excess
532 * Two inputs: one is a string or NULL. If non-NULL the pointer
533 * should point to a string containing the following exact text:
534 * "Software\Microsoft\Windows\CurrentVersion\Policies".
535 * The other input is unused.
538 * If the input is non-NULL and does not point to a string containing
539 * that exact text the routine will do nothing.
541 * If the text does match or the pointer is NULL, then the routine
542 * will init SHRestricted()'s policy cache to all 0xffffffff and
543 * returns 0xffffffff as well.
545 * I haven't yet run into anything calling this with inputs other than
546 * (NULL, NULL), so I may have the inputs reversed.
549 BOOL WINAPI SHInitRestricted(LPSTR inpRegKey, LPSTR parm2)
553 TRACE("(%p, %p)\n", inpRegKey, parm2);
555 /* first check - if input is non-NULL and points to the secret
556 key string, then pass. Otherwise return 0.
559 if (inpRegKey != (LPSTR)NULL)
561 if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
563 /* doesn't match, fail */
568 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
569 for (i = 0; i < SHELL_MAX_POLICIES; i++)
571 sh32_policy_table[i].cache = SHELL_NO_POLICY;
574 return SHELL_NO_POLICY;