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)
39 #include "shell32_main.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
45 #define SHELL_NO_POLICY 0xffffffff
47 typedef struct tagPOLICYDAT
49 DWORD policy
; /* policy value passed to SHRestricted */
50 LPCSTR appstr
; /* application str such as "Explorer" */
51 LPCSTR keystr
; /* name of the actual registry key / policy */
52 DWORD cache
; /* cached value or 0xffffffff for invalid */
53 } POLICYDATA
, *LPPOLICYDATA
;
55 /* registry strings */
56 static const CHAR strRegistryPolicyA
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
57 static const WCHAR strRegistryPolicyW
[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
58 's','o','f','t','\\','W','i','n','d','o','w','s','\\',
59 'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
60 '\\','P','o','l','i','c','i','e','s',0};
61 static const CHAR strPolicyA
[] = "Policy";
62 static const WCHAR strPolicyW
[] = {'P','o','l','i','c','y',0};
64 /* application strings */
66 static const char strExplorer
[] = {"Explorer"};
67 static const char strActiveDesk
[] = {"ActiveDesktop"};
68 static const char strWinOldApp
[] = {"WinOldApp"};
69 static const char strAddRemoveProgs
[] = {"AddRemoveProgs"};
73 static const char strNoFileURL
[] = {"NoFileUrl"};
74 static const char strNoFolderOptions
[] = {"NoFolderOptions"};
75 static const char strNoChangeStartMenu
[] = {"NoChangeStartMenu"};
76 static const char strNoWindowsUpdate
[] = {"NoWindowsUpdate"};
77 static const char strNoSetActiveDesktop
[] = {"NoSetActiveDesktop"};
78 static const char strNoForgetSoftwareUpdate
[] = {"NoForgetSoftwareUpdate"};
79 static const char strNoMSAppLogo
[] = {"NoMSAppLogo5ChannelNotify"};
80 static const char strForceCopyACLW
[] = {"ForceCopyACLWithFile"};
81 static const char strNoResolveTrk
[] = {"NoResolveTrack"};
82 static const char strNoResolveSearch
[] = {"NoResolveSearch"};
83 static const char strNoEditComponent
[] = {"NoEditingComponents"};
84 static const char strNoMovingBand
[] = {"NoMovingBands"};
85 static const char strNoCloseDragDrop
[] = {"NoCloseDragDropBands"};
86 static const char strNoCloseComponent
[] = {"NoClosingComponents"};
87 static const char strNoDelComponent
[] = {"NoDeletingComponents"};
88 static const char strNoAddComponent
[] = {"NoAddingComponents"};
89 static const char strNoComponent
[] = {"NoComponents"};
90 static const char strNoChangeWallpaper
[] = {"NoChangingWallpaper"};
91 static const char strNoHTMLWallpaper
[] = {"NoHTMLWallpaper"};
92 static const char strNoCustomWebView
[] = {"NoCustomizeWebView"};
93 static const char strClassicShell
[] = {"ClassicShell"};
94 static const char strClearRecentDocs
[] = {"ClearRecentDocsOnExit"};
95 static const char strNoFavoritesMenu
[] = {"NoFavoritesMenu"};
96 static const char strNoActiveDesktopChanges
[] = {"NoActiveDesktopChanges"};
97 static const char strNoActiveDesktop
[] = {"NoActiveDesktop"};
98 static const char strNoRecentDocMenu
[] = {"NoRecentDocsMenu"};
99 static const char strNoRecentDocHistory
[] = {"NoRecentDocsHistory"};
100 static const char strNoInetIcon
[] = {"NoInternetIcon"};
101 static const char strNoStngsWizard
[] = {"NoSettingsWizards"};
102 static const char strNoLogoff
[] = {"NoLogoff"};
103 static const char strNoNetConDis
[] = {"NoNetConnectDisconnect"};
104 static const char strNoContextMenu
[] = {"NoViewContextMenu"};
105 static const char strNoTryContextMenu
[] = {"NoTrayContextMenu"};
106 static const char strNoWebMenu
[] = {"NoWebMenu"};
107 static const char strLnkResolveIgnoreLnkInfo
[] = {"LinkResolveIgnoreLinkInfo"};
108 static const char strNoCommonGroups
[] = {"NoCommonGroups"};
109 static const char strEnforceShlExtSecurity
[] = {"EnforceShellExtensionSecurity"};
110 static const char strNoRealMode
[] = {"NoRealMode"};
111 static const char strMyDocsOnNet
[] = {"MyDocsOnNet"};
112 static const char strNoStartMenuSubfolder
[] = {"NoStartMenuSubFolders"};
113 static const char strNoAddPrinters
[] = {"NoAddPrinter"};
114 static const char strNoDeletePrinters
[] = {"NoDeletePrinter"};
115 static const char strNoPrintTab
[] = {"NoPrinterTabs"};
116 static const char strRestrictRun
[] = {"RestrictRun"};
117 static const char strNoStartBanner
[] = {"NoStartBanner"};
118 static const char strNoNetworkNeighborhood
[] = {"NoNetHood"};
119 static const char strNoDriveTypeAtRun
[] = {"NoDriveTypeAutoRun"};
120 static const char strNoDrivesAutoRun
[] = {"NoDriveAutoRun"};
121 static const char strNoDrives
[] = {"NoDrives"};
122 static const char strNoFind
[] = {"NoFind"};
123 static const char strNoDesktop
[] = {"NoDesktop"};
124 static const char strNoSetTaskBar
[] = {"NoSetTaskbar"};
125 static const char strNoSetFld
[] = {"NoSetFolders"};
126 static const char strNoFileMenu
[] = {"NoFileMenu"};
127 static const char strNoSavSetng
[] = {"NoSaveSettings"};
128 static const char strNoClose
[] = {"NoClose"};
129 static const char strNoRun
[] = {"NoRun"};
131 /* policy data array */
132 POLICYDATA sh32_policy_table
[] =
203 strNoNetworkNeighborhood
,
239 strNoStartMenuSubfolder
,
257 strEnforceShlExtSecurity
,
263 strLnkResolveIgnoreLnkInfo
,
323 strNoRecentDocHistory
,
341 strNoActiveDesktopChanges
,
377 strNoChangeWallpaper
,
449 strNoForgetSoftwareUpdate
,
455 strNoSetActiveDesktop
,
467 strNoChangeStartMenu
,
497 "MemCheckBoxInRunDlg",
527 "NoAddRemovePrograms",
545 "NoWindowsSetupPage",
551 "NoChangeMappedDriveLabel",
557 "NoChangeMappedDriveComment",
569 "NoNetworkConnections",
575 "ForceStartMenuLogoff",
587 "NoCustomizeThisFolder",
599 "AllowFrenchEncryption",
605 "DontShowSuperHidden",
611 "NoShellSearchButton",
623 "NoRunasInstallPrompt",
629 "PromptRunasInstallNetPath",
635 "NoManageMyComputerVerb",
641 "NoRecentDocsNetHood",
695 "DisableLocalMachineRun",
701 "DisableCurrentUserRun",
707 "DisableLocalMachineRunOnce",
713 "DisableCurrentUserRunOnce",
719 "ForceActiveDesktopOn",
743 "StartRunNoHOMEPATH",
772 /*************************************************************************
773 * SHRestricted [SHELL32.100]
775 * Get the value associated with a policy Id.
781 * The queried value for the policy.
784 * Exported by ordinal.
785 * This function caches the retrieved values to prevent unnecessary registry access,
786 * if SHInitRestricted() was previously called.
789 * a: MS System Policy Editor.
790 * b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
791 * c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
793 DWORD WINAPI
SHRestricted (DWORD policy
)
797 DWORD retval
, datsize
= 4;
800 TRACE("(%08lx)\n", policy
);
802 /* scan to see if we know this policy ID */
803 for (p
= sh32_policy_table
; p
->policy
; p
++)
805 if (policy
== p
->policy
)
813 /* we don't know this policy, return 0 */
814 TRACE("unknown policy: (%08lx)\n", policy
);
818 /* we have a known policy */
820 /* first check if this policy has been cached, return it if so */
821 if (p
->cache
!= SHELL_NO_POLICY
)
826 lstrcpyA(regstr
, strRegistryPolicyA
);
827 lstrcatA(regstr
, p
->appstr
);
829 /* return 0 and don't set the cache if any registry errors occur */
831 if (RegOpenKeyA(HKEY_CURRENT_USER
, regstr
, &xhkey
) == ERROR_SUCCESS
)
833 if (RegQueryValueExA(xhkey
, p
->keystr
, NULL
, NULL
, (LPBYTE
)&retval
, &datsize
) == ERROR_SUCCESS
)
842 /*************************************************************************
843 * SHInitRestricted [SHELL32.244]
845 * Initialise the policy cache to speed up calls to SHRestricted().
848 * unused [I] Reserved.
849 * inpRegKey [I] Registry key to scan.
852 * Success: -1. The policy cache is initialised.
853 * Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
854 * "Software\Microsoft\Windows\CurrentVersion\Policies".
857 * Exported by ordinal. Introduced in Win98.
859 BOOL WINAPI
SHInitRestricted(LPCVOID unused
, LPCVOID inpRegKey
)
863 TRACE("(%p, %p)\n", unused
, inpRegKey
);
865 /* first check - if input is non-NULL and points to the secret
866 key string, then pass. Otherwise return 0.
868 if (inpRegKey
!= NULL
)
870 if (SHELL_OsIsUnicode())
872 if (lstrcmpiW((LPWSTR
)inpRegKey
, strRegistryPolicyW
) &&
873 lstrcmpiW((LPWSTR
)inpRegKey
, strPolicyW
))
874 /* doesn't match, fail */
879 if (lstrcmpiA((LPSTR
)inpRegKey
, strRegistryPolicyA
) &&
880 lstrcmpiA((LPSTR
)inpRegKey
, strPolicyA
))
881 /* doesn't match, fail */
886 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
887 for (p
= sh32_policy_table
; p
->policy
; p
++)
889 p
->cache
= SHELL_NO_POLICY
;
891 return SHELL_NO_POLICY
;