Added sample config file in the new format.
[wine/multimedia.git] / dlls / shell32 / shpolicy.c
blob547bfaabd282824aa4b81cf5e161f3c6c157c0f2
1 /*
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
11 * this file...
13 * Up to date as of SHELL32 v4.72 (Win98, Win95 with MSIE 5)
16 #include <stdlib.h>
17 #include <string.h>
19 #include "windef.h"
20 #include "wingdi.h"
21 #include "winerror.h"
22 #include "winreg.h"
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"};
48 /* key strings */
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[] =
113 0x1,
114 strExplorer,
115 strNoRun,
116 SHELL_NO_POLICY
119 0x2,
120 strExplorer,
121 strNoClose,
122 SHELL_NO_POLICY
125 0x4,
126 strExplorer,
127 strNoSavSetng,
128 SHELL_NO_POLICY
131 0x8,
132 strExplorer,
133 strNoFileMenu,
134 SHELL_NO_POLICY
137 0x10,
138 strExplorer,
139 strNoSetFld,
140 SHELL_NO_POLICY
143 0x20,
144 strExplorer,
145 strNoSetTaskBar,
146 SHELL_NO_POLICY
149 0x40,
150 strExplorer,
151 strNoDesktop,
152 SHELL_NO_POLICY
155 0x80,
156 strExplorer,
157 strNoFind,
158 SHELL_NO_POLICY
161 0x100,
162 strExplorer,
163 strNoDrives,
164 SHELL_NO_POLICY
167 0x200,
168 strExplorer,
169 strNoDrivesAutoRun,
170 SHELL_NO_POLICY
173 0x400,
174 strExplorer,
175 strNoDriveTypeAtRun,
176 SHELL_NO_POLICY
179 0x800,
180 strExplorer,
181 strNoNetworkNeighborhood,
182 SHELL_NO_POLICY
185 0x1000,
186 strExplorer,
187 strNoStartBanner,
188 SHELL_NO_POLICY
191 0x2000,
192 strExplorer,
193 strRestrictRun,
194 SHELL_NO_POLICY
197 0x4000,
198 strExplorer,
199 strNoPrintTab,
200 SHELL_NO_POLICY
203 0x8000,
204 strExplorer,
205 strNoDeletePrinters,
206 SHELL_NO_POLICY
209 0x10000,
210 strExplorer,
211 strNoAddPrinters,
212 SHELL_NO_POLICY
215 0x20000,
216 strExplorer,
217 strNoStartMenuSubfolder,
218 SHELL_NO_POLICY
221 0x40000,
222 strExplorer,
223 strMyDocsOnNet,
224 SHELL_NO_POLICY
227 0x80000,
228 strWinOldApp,
229 strNoRealMode,
230 SHELL_NO_POLICY
233 0x100000,
234 strExplorer,
235 strEnforceShlExtSecurity,
236 SHELL_NO_POLICY
239 0x200000,
240 strExplorer,
241 strLnkResolveIgnoreLnkInfo,
242 SHELL_NO_POLICY
245 0x400000,
246 strExplorer,
247 strNoCommonGroups,
248 SHELL_NO_POLICY
251 0x1000000,
252 strExplorer,
253 strNoWebMenu,
254 SHELL_NO_POLICY
257 0x2000000,
258 strExplorer,
259 strNoTryContextMenu,
260 SHELL_NO_POLICY
263 0x4000000,
264 strExplorer,
265 strNoContextMenu,
266 SHELL_NO_POLICY
269 0x8000000,
270 strExplorer,
271 strNoNetConDis,
272 SHELL_NO_POLICY
275 0x10000000,
276 strExplorer,
277 strNoLogoff,
278 SHELL_NO_POLICY
281 0x20000000,
282 strExplorer,
283 strNoStngsWizard,
284 SHELL_NO_POLICY
287 0x40000001,
288 strExplorer,
289 strNoInetIcon,
290 SHELL_NO_POLICY
293 0x40000002,
294 strExplorer,
295 strNoRecentDocHistory,
296 SHELL_NO_POLICY
299 0x40000003,
300 strExplorer,
301 strNoRecentDocMenu,
302 SHELL_NO_POLICY
305 0x40000004,
306 strExplorer,
307 strNoActiveDesktop,
308 SHELL_NO_POLICY
311 0x40000005,
312 strExplorer,
313 strNoActiveDesktopChanges,
314 SHELL_NO_POLICY
317 0x40000006,
318 strExplorer,
319 strNoFavoritesMenu,
320 SHELL_NO_POLICY
323 0x40000007,
324 strExplorer,
325 strClearRecentDocs,
326 SHELL_NO_POLICY
329 0x40000008,
330 strExplorer,
331 strClassicShell,
332 SHELL_NO_POLICY
335 0x40000009,
336 strExplorer,
337 strNoCustomWebView,
338 SHELL_NO_POLICY
341 0x40000010,
342 strActiveDesk,
343 strNoHTMLWallpaper,
344 SHELL_NO_POLICY
347 0x40000011,
348 strActiveDesk,
349 strNoChangeWallpaper,
350 SHELL_NO_POLICY
353 0x40000012,
354 strActiveDesk,
355 strNoComponent,
356 SHELL_NO_POLICY
359 0x40000013,
360 strActiveDesk,
361 strNoAddComponent,
362 SHELL_NO_POLICY
365 0x40000014,
366 strActiveDesk,
367 strNoDelComponent,
368 SHELL_NO_POLICY
371 0x40000015,
372 strActiveDesk,
373 strNoCloseComponent,
374 SHELL_NO_POLICY
377 0x40000016,
378 strActiveDesk,
379 strNoCloseDragDrop,
380 SHELL_NO_POLICY
383 0x40000017,
384 strActiveDesk,
385 strNoMovingBand,
386 SHELL_NO_POLICY
389 0x40000018,
390 strActiveDesk,
391 strNoEditComponent,
392 SHELL_NO_POLICY
395 0x40000019,
396 strExplorer,
397 strNoResolveSearch,
398 SHELL_NO_POLICY
401 0x4000001a,
402 strExplorer,
403 strNoResolveTrk,
404 SHELL_NO_POLICY
407 0x4000001b,
408 strExplorer,
409 strForceCopyACLW,
410 SHELL_NO_POLICY
413 0x4000001c,
414 strExplorer,
415 strNoMSAppLogo,
416 SHELL_NO_POLICY
419 0x4000001d,
420 strExplorer,
421 strNoForgetSoftwareUpdate,
422 SHELL_NO_POLICY
425 0x4000001e,
426 strExplorer,
427 strNoSetActiveDesktop,
428 SHELL_NO_POLICY
431 0x4000001f,
432 strExplorer,
433 strNoWindowsUpdate,
434 SHELL_NO_POLICY
437 0x40000020,
438 strExplorer,
439 strNoChangeStartMenu,
440 SHELL_NO_POLICY
443 0x40000021,
444 strExplorer,
445 strNoFolderOptions,
446 SHELL_NO_POLICY
449 0x50000024,
450 strExplorer,
451 strNoFileURL,
452 SHELL_NO_POLICY
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.
463 * NOTES
464 * exported by ordinal
466 * REFERENCES:
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) {
472 char regstr[256];
473 HKEY xhkey;
474 DWORD retval, polidx, i, datsize = 4;
476 TRACE("(%08lx)\n",pol);
478 polidx = -1;
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)
485 polidx = i;
486 break;
490 if (polidx == -1)
492 /* we don't know this policy, return 0 */
493 TRACE("unknown policy: (%08lx)\n", pol);
494 return 0;
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 */
508 retval = 0;
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;
516 RegCloseKey(xhkey);
519 return 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
527 * registry access.
529 * INPUTS
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.
535 * NOTES
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)
549 int i;
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 */
562 return 0;
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;