2 * shpolicy.c - Data for shell/system policies.
4 * Copyright 1999 Ian Schmidt <ischmidt@cfl.rr.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Some of these policies can be tweaked via the System Policy
23 * Editor which came with the Win95 Migration Guide, although
24 * there doesn't appear to be an updated Win98 version that
25 * would handle the many new policies introduced since then.
26 * You could easily write one with the information in
29 * Up to date as of SHELL32 v5.00 (W2K)
41 #include "shell32_main.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
47 #define SHELL_NO_POLICY 0xffffffff
49 typedef struct tagPOLICYDAT
51 DWORD policy
; /* policy value passed to SHRestricted */
52 LPCSTR appstr
; /* application str such as "Explorer" */
53 LPCSTR keystr
; /* name of the actual registry key / policy */
54 DWORD cache
; /* cached value or 0xffffffff for invalid */
55 } POLICYDATA
, *LPPOLICYDATA
;
57 /* registry strings */
58 static const CHAR strRegistryPolicyA
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
59 static const WCHAR strRegistryPolicyW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
60 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
61 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
62 '\\','P','o','l','i','c','i','e','s',0};
63 static const CHAR strPolicyA
[] = "Policy";
64 static const WCHAR strPolicyW
[] = {'P','o','l','i','c','y',0};
66 /* application strings */
68 static const char strExplorer
[] = {"Explorer"};
69 static const char strActiveDesk
[] = {"ActiveDesktop"};
70 static const char strWinOldApp
[] = {"WinOldApp"};
71 static const char strAddRemoveProgs
[] = {"AddRemoveProgs"};
75 static const char strNoFileURL
[] = {"NoFileUrl"};
76 static const char strNoFolderOptions
[] = {"NoFolderOptions"};
77 static const char strNoChangeStartMenu
[] = {"NoChangeStartMenu"};
78 static const char strNoWindowsUpdate
[] = {"NoWindowsUpdate"};
79 static const char strNoSetActiveDesktop
[] = {"NoSetActiveDesktop"};
80 static const char strNoForgetSoftwareUpdate
[] = {"NoForgetSoftwareUpdate"};
81 static const char strNoMSAppLogo
[] = {"NoMSAppLogo5ChannelNotify"};
82 static const char strForceCopyACLW
[] = {"ForceCopyACLWithFile"};
83 static const char strNoResolveTrk
[] = {"NoResolveTrack"};
84 static const char strNoResolveSearch
[] = {"NoResolveSearch"};
85 static const char strNoEditComponent
[] = {"NoEditingComponents"};
86 static const char strNoMovingBand
[] = {"NoMovingBands"};
87 static const char strNoCloseDragDrop
[] = {"NoCloseDragDropBands"};
88 static const char strNoCloseComponent
[] = {"NoClosingComponents"};
89 static const char strNoDelComponent
[] = {"NoDeletingComponents"};
90 static const char strNoAddComponent
[] = {"NoAddingComponents"};
91 static const char strNoComponent
[] = {"NoComponents"};
92 static const char strNoChangeWallpaper
[] = {"NoChangingWallpaper"};
93 static const char strNoHTMLWallpaper
[] = {"NoHTMLWallpaper"};
94 static const char strNoCustomWebView
[] = {"NoCustomizeWebView"};
95 static const char strClassicShell
[] = {"ClassicShell"};
96 static const char strClearRecentDocs
[] = {"ClearRecentDocsOnExit"};
97 static const char strNoFavoritesMenu
[] = {"NoFavoritesMenu"};
98 static const char strNoActiveDesktopChanges
[] = {"NoActiveDesktopChanges"};
99 static const char strNoActiveDesktop
[] = {"NoActiveDesktop"};
100 static const char strNoRecentDocMenu
[] = {"NoRecentDocsMenu"};
101 static const char strNoRecentDocHistory
[] = {"NoRecentDocsHistory"};
102 static const char strNoInetIcon
[] = {"NoInternetIcon"};
103 static const char strNoStngsWizard
[] = {"NoSettingsWizards"};
104 static const char strNoLogoff
[] = {"NoLogoff"};
105 static const char strNoNetConDis
[] = {"NoNetConnectDisconnect"};
106 static const char strNoContextMenu
[] = {"NoViewContextMenu"};
107 static const char strNoTryContextMenu
[] = {"NoTrayContextMenu"};
108 static const char strNoWebMenu
[] = {"NoWebMenu"};
109 static const char strLnkResolveIgnoreLnkInfo
[] = {"LinkResolveIgnoreLinkInfo"};
110 static const char strNoCommonGroups
[] = {"NoCommonGroups"};
111 static const char strEnforceShlExtSecurity
[] = {"EnforceShellExtensionSecurity"};
112 static const char strNoRealMode
[] = {"NoRealMode"};
113 static const char strMyDocsOnNet
[] = {"MyDocsOnNet"};
114 static const char strNoStartMenuSubfolder
[] = {"NoStartMenuSubFolders"};
115 static const char strNoAddPrinters
[] = {"NoAddPrinter"};
116 static const char strNoDeletePrinters
[] = {"NoDeletePrinter"};
117 static const char strNoPrintTab
[] = {"NoPrinterTabs"};
118 static const char strRestrictRun
[] = {"RestrictRun"};
119 static const char strNoStartBanner
[] = {"NoStartBanner"};
120 static const char strNoNetworkNeighborhood
[] = {"NoNetHood"};
121 static const char strNoDriveTypeAtRun
[] = {"NoDriveTypeAutoRun"};
122 static const char strNoDrivesAutoRun
[] = {"NoDriveAutoRun"};
123 static const char strNoDrives
[] = {"NoDrives"};
124 static const char strNoFind
[] = {"NoFind"};
125 static const char strNoDesktop
[] = {"NoDesktop"};
126 static const char strNoSetTaskBar
[] = {"NoSetTaskbar"};
127 static const char strNoSetFld
[] = {"NoSetFolders"};
128 static const char strNoFileMenu
[] = {"NoFileMenu"};
129 static const char strNoSavSetng
[] = {"NoSaveSettings"};
130 static const char strNoClose
[] = {"NoClose"};
131 static const char strNoRun
[] = {"NoRun"};
133 /* policy data array */
134 POLICYDATA sh32_policy_table
[] =
205 strNoNetworkNeighborhood
,
241 strNoStartMenuSubfolder
,
259 strEnforceShlExtSecurity
,
265 strLnkResolveIgnoreLnkInfo
,
325 strNoRecentDocHistory
,
343 strNoActiveDesktopChanges
,
379 strNoChangeWallpaper
,
451 strNoForgetSoftwareUpdate
,
457 strNoSetActiveDesktop
,
469 strNoChangeStartMenu
,
499 "MemCheckBoxInRunDlg",
529 "NoAddRemovePrograms",
547 "NoWindowsSetupPage",
553 "NoChangeMappedDriveLabel",
559 "NoChangeMappedDriveComment",
571 "NoNetworkConnections",
577 "ForceStartMenuLogoff",
589 "NoCustomizeThisFolder",
601 "AllowFrenchEncryption",
607 "DontShowSuperHidden",
613 "NoShellSearchButton",
625 "NoRunasInstallPrompt",
631 "PromptRunasInstallNetPath",
637 "NoManageMyComputerVerb",
643 "NoRecentDocsNetHood",
697 "DisableLocalMachineRun",
703 "DisableCurrentUserRun",
709 "DisableLocalMachineRunOnce",
715 "DisableCurrentUserRunOnce",
721 "ForceActiveDesktopOn",
745 "StartRunNoHOMEPATH",
774 /*************************************************************************
775 * SHRestricted [SHELL32.100]
777 * Get the value associated with a policy Id.
783 * The queried value for the policy.
786 * Exported by ordinal.
787 * This function caches the retrieved values to prevent unnecessary registry access,
788 * if SHInitRestricted() was previously called.
791 * a: MS System Policy Editor.
792 * b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
793 * c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
795 DWORD WINAPI
SHRestricted (DWORD policy
)
799 DWORD retval
, datsize
= 4;
802 TRACE("(%08lx)\n", policy
);
804 /* scan to see if we know this policy ID */
805 for (p
= sh32_policy_table
; p
->policy
; p
++)
807 if (policy
== p
->policy
)
815 /* we don't know this policy, return 0 */
816 TRACE("unknown policy: (%08lx)\n", policy
);
820 /* we have a known policy */
822 /* first check if this policy has been cached, return it if so */
823 if (p
->cache
!= SHELL_NO_POLICY
)
828 lstrcpyA(regstr
, strRegistryPolicyA
);
829 lstrcatA(regstr
, p
->appstr
);
831 /* return 0 and don't set the cache if any registry errors occur */
833 if (RegOpenKeyA(HKEY_CURRENT_USER
, regstr
, &xhkey
) == ERROR_SUCCESS
)
835 if (RegQueryValueExA(xhkey
, p
->keystr
, NULL
, NULL
, (LPBYTE
)&retval
, &datsize
) == ERROR_SUCCESS
)
844 /*************************************************************************
845 * SHInitRestricted [SHELL32.244]
847 * Initialise the policy cache to speed up calls to SHRestricted().
850 * unused [I] Reserved.
851 * inpRegKey [I] Registry key to scan.
854 * Success: -1. The policy cache is initialised.
855 * Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
856 * "Software\Microsoft\Windows\CurrentVersion\Policies".
859 * Exported by ordinal. Introduced in Win98.
861 BOOL WINAPI
SHInitRestricted(LPCVOID unused
, LPCVOID inpRegKey
)
865 TRACE("(%p, %p)\n", unused
, inpRegKey
);
867 /* first check - if input is non-NULL and points to the secret
868 key string, then pass. Otherwise return 0.
870 if (inpRegKey
!= NULL
)
872 if (SHELL_OsIsUnicode())
874 if (lstrcmpiW((LPWSTR
)inpRegKey
, strRegistryPolicyW
) &&
875 lstrcmpiW((LPWSTR
)inpRegKey
, strPolicyW
))
876 /* doesn't match, fail */
881 if (lstrcmpiA((LPSTR
)inpRegKey
, strRegistryPolicyA
) &&
882 lstrcmpiA((LPSTR
)inpRegKey
, strPolicyA
))
883 /* doesn't match, fail */
888 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
889 for (p
= sh32_policy_table
; p
->policy
; p
++)
891 p
->cache
= SHELL_NO_POLICY
;
893 return SHELL_NO_POLICY
;