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 "debugtools.h"
24 #include "wine/winuser16.h"
26 DEFAULT_DEBUG_CHANNEL(shell
);
28 #define SHELL_MAX_POLICIES 57
30 #define SHELL_NO_POLICY 0xffffffff
32 typedef struct tagPOLICYDAT
34 DWORD polflags
; /* flags value passed to SHRestricted */
35 LPSTR appstr
; /* application str such as "Explorer" */
36 LPSTR keystr
; /* name of the actual registry key / policy */
37 DWORD cache
; /* cached value or 0xffffffff for invalid */
38 } POLICYDATA
, *LPPOLICYDATA
;
40 //extern POLICYDATA sh32_policy_table[SHELL_MAX_POLICIES];
42 /* application strings */
44 static char strExplorer
[] = {"Explorer"};
45 static char strActiveDesk
[] = {"ActiveDesktop"};
46 static char strWinOldApp
[] = {"WinOldApp"};
50 static char strNoFileURL
[] = {"NoFileUrl"};
51 static char strNoFolderOptions
[] = {"NoFolderOptions"};
52 static char strNoChangeStartMenu
[] = {"NoChangeStartMenu"};
53 static char strNoWindowsUpdate
[] = {"NoWindowsUpdate"};
54 static char strNoSetActiveDesktop
[] = {"NoSetActiveDesktop"};
55 static char strNoForgetSoftwareUpdate
[] = {"NoForgetSoftwareUpdate"};
56 static char strNoMSAppLogo
[] = {"NoMSAppLogo5ChannelNotify"};
57 static char strForceCopyACLW
[] = {"ForceCopyACLWithFile"};
58 static char strNoResolveTrk
[] = {"NoResolveTrack"};
59 static char strNoResolveSearch
[] = {"NoResolveSearch"};
60 static char strNoEditComponent
[] = {"NoEditingComponents"};
61 static char strNoMovingBand
[] = {"NoMovingBands"};
62 static char strNoCloseDragDrop
[] = {"NoCloseDragDropBands"};
63 static char strNoCloseComponent
[] = {"NoClosingComponents"};
64 static char strNoDelComponent
[] = {"NoDeletingComponents"};
65 static char strNoAddComponent
[] = {"NoAddingComponents"};
66 static char strNoComponent
[] = {"NoComponents"};
67 static char strNoChangeWallpaper
[] = {"NoChangingWallpaper"};
68 static char strNoHTMLWallpaper
[] = {"NoHTMLWallpaper"};
69 static char strNoCustomWebView
[] = {"NoCustomizeWebView"};
70 static char strClassicShell
[] = {"ClassicShell"};
71 static char strClearRecentDocs
[] = {"ClearRecentDocsOnExit"};
72 static char strNoFavoritesMenu
[] = {"NoFavoritesMenu"};
73 static char strNoActiveDesktopChanges
[] = {"NoActiveDesktopChanges"};
74 static char strNoActiveDesktop
[] = {"NoActiveDesktop"};
75 static char strNoRecentDocMenu
[] = {"NoRecentDocsMenu"};
76 static char strNoRecentDocHistory
[] = {"NoRecentDocsHistory"};
77 static char strNoInetIcon
[] = {"NoInternetIcon"};
78 static char strNoStngsWizard
[] = {"NoSettingsWizards"};
79 static char strNoLogoff
[] = {"NoLogoff"};
80 static char strNoNetConDis
[] = {"NoNetConnectDisconnect"};
81 static char strNoContextMenu
[] = {"NoViewContextMenu"};
82 static char strNoTryContextMenu
[] = {"NoTrayContextMenu"};
83 static char strNoWebMenu
[] = {"NoWebMenu"};
84 static char strLnkResolveIgnoreLnkInfo
[] = {"LinkResolveIgnoreLinkInfo"};
85 static char strNoCommonGroups
[] = {"NoCommonGroups"};
86 static char strEnforceShlExtSecurity
[] = {"EnforceShellExtensionSecurity"};
87 static char strNoRealMode
[] = {"NoRealMode"};
88 static char strMyDocsOnNet
[] = {"MyDocsOnNet"};
89 static char strNoStartMenuSubfolder
[] = {"NoStartMenuSubFolders"};
90 static char strNoAddPrinters
[] = {"NoAddPrinter"};
91 static char strNoDeletePrinters
[] = {"NoDeletePrinter"};
92 static char strNoPrintTab
[] = {"NoPrinterTabs"};
93 static char strRestrictRun
[] = {"RestrictRun"};
94 static char strNoStartBanner
[] = {"NoStartBanner"};
95 static char strNoNetworkNeighborhood
[] = {"NoNetHood"};
96 static char strNoDriveTypeAtRun
[] = {"NoDriveTypeAutoRun"};
97 static char strNoDrivesAutoRun
[] = {"NoDriveAutoRun"};
98 static char strNoDrives
[] = {"NoDrives"};
99 static char strNoFind
[] = {"NoFind"};
100 static char strNoDesktop
[] = {"NoDesktop"};
101 static char strNoSetTaskBar
[] = {"NoSetTaskbar"};
102 static char strNoSetFld
[] = {"NoSetFolders"};
103 static char strNoFileMenu
[] = {"NoFileMenu"};
104 static char strNoSavSetng
[] = {"NoSaveSettings"};
105 static char strNoClose
[] = {"NoClose"};
106 static char strNoRun
[] = {"NoRun"};
108 /* policy data array */
110 POLICYDATA sh32_policy_table
[] =
181 strNoNetworkNeighborhood
,
217 strNoStartMenuSubfolder
,
235 strEnforceShlExtSecurity
,
241 strLnkResolveIgnoreLnkInfo
,
295 strNoRecentDocHistory
,
313 strNoActiveDesktopChanges
,
349 strNoChangeWallpaper
,
421 strNoForgetSoftwareUpdate
,
427 strNoSetActiveDesktop
,
439 strNoChangeStartMenu
,
456 /*************************************************************************
457 * SHRestricted [SHELL32.100]
459 * walks through policy table, queries <app> key, <type> value, returns
460 * queried (DWORD) value, and caches it between called to SHInitRestricted
461 * to prevent unnecessary registry access.
464 * exported by ordinal
467 * MS System Policy Editor
468 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
469 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
471 DWORD WINAPI
SHRestricted (DWORD pol
) {
474 DWORD retval
, polidx
, i
, datsize
= 4;
476 TRACE("(%08lx)\n",pol
);
480 /* scan to see if we know this policy ID */
481 for (i
= 0; i
< SHELL_MAX_POLICIES
; i
++)
483 if (pol
== sh32_policy_table
[i
].polflags
)
492 /* we don't know this policy, return 0 */
493 TRACE("unknown policy: (%08lx)\n", pol
);
497 /* we have a known policy */
498 strcpy(regstr
, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
499 strcat(regstr
, sh32_policy_table
[polidx
].appstr
);
501 /* first check if this policy has been cached, return it if so */
502 if (sh32_policy_table
[polidx
].cache
!= SHELL_NO_POLICY
)
504 return sh32_policy_table
[polidx
].cache
;
507 /* return 0 and don't set the cache if any registry errors occur */
509 if (RegOpenKeyA(HKEY_CURRENT_USER
, regstr
, &xhkey
) == ERROR_SUCCESS
)
511 if (RegQueryValueExA(xhkey
, sh32_policy_table
[polidx
].keystr
, NULL
, NULL
, (LPBYTE
)&retval
, &datsize
) == ERROR_SUCCESS
)
513 sh32_policy_table
[polidx
].cache
= retval
;
522 /*************************************************************************
523 * SHInitRestricted [SHELL32.244]
525 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
526 * Inits the policy cache used by SHRestricted to avoid excess
530 * Two inputs: one is a string or NULL. If non-NULL the pointer
531 * should point to a string containing the following exact text:
532 * "Software\Microsoft\Windows\CurrentVersion\Policies".
533 * The other input is unused.
536 * If the input is non-NULL and does not point to a string containing
537 * that exact text the routine will do nothing.
539 * If the text does match or the pointer is NULL, then the routine
540 * will init SHRestricted()'s policy cache to all 0xffffffff and
541 * returns 0xffffffff as well.
543 * I haven't yet run into anything calling this with inputs other than
544 * (NULL, NULL), so I may have the inputs reversed.
547 BOOL WINAPI
SHInitRestricted(LPSTR inpRegKey
, LPSTR parm2
)
551 TRACE("(%p, %p)\n", inpRegKey
, parm2
);
553 /* first check - if input is non-NULL and points to the secret
554 key string, then pass. Otherwise return 0.
557 if (inpRegKey
!= (LPSTR
)NULL
)
559 if (lstrcmpiA(inpRegKey
, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
561 /* doesn't match, fail */
566 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
567 for (i
= 0; i
< SHELL_MAX_POLICIES
; i
++)
569 sh32_policy_table
[i
].cache
= SHELL_NO_POLICY
;
572 return SHELL_NO_POLICY
;