Added the DFCS_{HOT,TRANSPARENT} definitions.
[wine/gsoc_dplay.git] / dlls / shell32 / shpolicy.c
blob5c336d733c4d9b152d7a4e6a00227c0992eca3ce
1 /*
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
20 * NOTES:
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
27 * this file...
29 * Up to date as of SHELL32 v4.72 (Win98, Win95 with MSIE 5)
32 #include <stdlib.h>
33 #include <string.h>
35 #include "windef.h"
36 #include "winerror.h"
37 #include "winreg.h"
39 #include "undocshell.h"
40 #include "wine/winuser16.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(shell);
46 #define SHELL_MAX_POLICIES 57
48 #define SHELL_NO_POLICY 0xffffffff
50 typedef struct tagPOLICYDAT
52 DWORD polflags; /* flags value passed to SHRestricted */
53 LPSTR appstr; /* application str such as "Explorer" */
54 LPSTR keystr; /* name of the actual registry key / policy */
55 DWORD cache; /* cached value or 0xffffffff for invalid */
56 } POLICYDATA, *LPPOLICYDATA;
58 //extern POLICYDATA sh32_policy_table[SHELL_MAX_POLICIES];
60 /* application strings */
62 static char strExplorer[] = {"Explorer"};
63 static char strActiveDesk[] = {"ActiveDesktop"};
64 static char strWinOldApp[] = {"WinOldApp"};
66 /* key strings */
68 static char strNoFileURL[] = {"NoFileUrl"};
69 static char strNoFolderOptions[] = {"NoFolderOptions"};
70 static char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
71 static char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
72 static char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
73 static char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
74 static char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
75 static char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
76 static char strNoResolveTrk[] = {"NoResolveTrack"};
77 static char strNoResolveSearch[] = {"NoResolveSearch"};
78 static char strNoEditComponent[] = {"NoEditingComponents"};
79 static char strNoMovingBand[] = {"NoMovingBands"};
80 static char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
81 static char strNoCloseComponent[] = {"NoClosingComponents"};
82 static char strNoDelComponent[] = {"NoDeletingComponents"};
83 static char strNoAddComponent[] = {"NoAddingComponents"};
84 static char strNoComponent[] = {"NoComponents"};
85 static char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
86 static char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
87 static char strNoCustomWebView[] = {"NoCustomizeWebView"};
88 static char strClassicShell[] = {"ClassicShell"};
89 static char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
90 static char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
91 static char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
92 static char strNoActiveDesktop[] = {"NoActiveDesktop"};
93 static char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
94 static char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
95 static char strNoInetIcon[] = {"NoInternetIcon"};
96 static char strNoStngsWizard[] = {"NoSettingsWizards"};
97 static char strNoLogoff[] = {"NoLogoff"};
98 static char strNoNetConDis[] = {"NoNetConnectDisconnect"};
99 static char strNoContextMenu[] = {"NoViewContextMenu"};
100 static char strNoTryContextMenu[] = {"NoTrayContextMenu"};
101 static char strNoWebMenu[] = {"NoWebMenu"};
102 static char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
103 static char strNoCommonGroups[] = {"NoCommonGroups"};
104 static char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
105 static char strNoRealMode[] = {"NoRealMode"};
106 static char strMyDocsOnNet[] = {"MyDocsOnNet"};
107 static char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
108 static char strNoAddPrinters[] = {"NoAddPrinter"};
109 static char strNoDeletePrinters[] = {"NoDeletePrinter"};
110 static char strNoPrintTab[] = {"NoPrinterTabs"};
111 static char strRestrictRun[] = {"RestrictRun"};
112 static char strNoStartBanner[] = {"NoStartBanner"};
113 static char strNoNetworkNeighborhood[] = {"NoNetHood"};
114 static char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
115 static char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
116 static char strNoDrives[] = {"NoDrives"};
117 static char strNoFind[] = {"NoFind"};
118 static char strNoDesktop[] = {"NoDesktop"};
119 static char strNoSetTaskBar[] = {"NoSetTaskbar"};
120 static char strNoSetFld[] = {"NoSetFolders"};
121 static char strNoFileMenu[] = {"NoFileMenu"};
122 static char strNoSavSetng[] = {"NoSaveSettings"};
123 static char strNoClose[] = {"NoClose"};
124 static char strNoRun[] = {"NoRun"};
126 /* policy data array */
128 POLICYDATA sh32_policy_table[] =
131 0x1,
132 strExplorer,
133 strNoRun,
134 SHELL_NO_POLICY
137 0x2,
138 strExplorer,
139 strNoClose,
140 SHELL_NO_POLICY
143 0x4,
144 strExplorer,
145 strNoSavSetng,
146 SHELL_NO_POLICY
149 0x8,
150 strExplorer,
151 strNoFileMenu,
152 SHELL_NO_POLICY
155 0x10,
156 strExplorer,
157 strNoSetFld,
158 SHELL_NO_POLICY
161 0x20,
162 strExplorer,
163 strNoSetTaskBar,
164 SHELL_NO_POLICY
167 0x40,
168 strExplorer,
169 strNoDesktop,
170 SHELL_NO_POLICY
173 0x80,
174 strExplorer,
175 strNoFind,
176 SHELL_NO_POLICY
179 0x100,
180 strExplorer,
181 strNoDrives,
182 SHELL_NO_POLICY
185 0x200,
186 strExplorer,
187 strNoDrivesAutoRun,
188 SHELL_NO_POLICY
191 0x400,
192 strExplorer,
193 strNoDriveTypeAtRun,
194 SHELL_NO_POLICY
197 0x800,
198 strExplorer,
199 strNoNetworkNeighborhood,
200 SHELL_NO_POLICY
203 0x1000,
204 strExplorer,
205 strNoStartBanner,
206 SHELL_NO_POLICY
209 0x2000,
210 strExplorer,
211 strRestrictRun,
212 SHELL_NO_POLICY
215 0x4000,
216 strExplorer,
217 strNoPrintTab,
218 SHELL_NO_POLICY
221 0x8000,
222 strExplorer,
223 strNoDeletePrinters,
224 SHELL_NO_POLICY
227 0x10000,
228 strExplorer,
229 strNoAddPrinters,
230 SHELL_NO_POLICY
233 0x20000,
234 strExplorer,
235 strNoStartMenuSubfolder,
236 SHELL_NO_POLICY
239 0x40000,
240 strExplorer,
241 strMyDocsOnNet,
242 SHELL_NO_POLICY
245 0x80000,
246 strWinOldApp,
247 strNoRealMode,
248 SHELL_NO_POLICY
251 0x100000,
252 strExplorer,
253 strEnforceShlExtSecurity,
254 SHELL_NO_POLICY
257 0x200000,
258 strExplorer,
259 strLnkResolveIgnoreLnkInfo,
260 SHELL_NO_POLICY
263 0x400000,
264 strExplorer,
265 strNoCommonGroups,
266 SHELL_NO_POLICY
269 0x1000000,
270 strExplorer,
271 strNoWebMenu,
272 SHELL_NO_POLICY
275 0x2000000,
276 strExplorer,
277 strNoTryContextMenu,
278 SHELL_NO_POLICY
281 0x4000000,
282 strExplorer,
283 strNoContextMenu,
284 SHELL_NO_POLICY
287 0x8000000,
288 strExplorer,
289 strNoNetConDis,
290 SHELL_NO_POLICY
293 0x10000000,
294 strExplorer,
295 strNoLogoff,
296 SHELL_NO_POLICY
299 0x20000000,
300 strExplorer,
301 strNoStngsWizard,
302 SHELL_NO_POLICY
305 0x40000001,
306 strExplorer,
307 strNoInetIcon,
308 SHELL_NO_POLICY
311 0x40000002,
312 strExplorer,
313 strNoRecentDocHistory,
314 SHELL_NO_POLICY
317 0x40000003,
318 strExplorer,
319 strNoRecentDocMenu,
320 SHELL_NO_POLICY
323 0x40000004,
324 strExplorer,
325 strNoActiveDesktop,
326 SHELL_NO_POLICY
329 0x40000005,
330 strExplorer,
331 strNoActiveDesktopChanges,
332 SHELL_NO_POLICY
335 0x40000006,
336 strExplorer,
337 strNoFavoritesMenu,
338 SHELL_NO_POLICY
341 0x40000007,
342 strExplorer,
343 strClearRecentDocs,
344 SHELL_NO_POLICY
347 0x40000008,
348 strExplorer,
349 strClassicShell,
350 SHELL_NO_POLICY
353 0x40000009,
354 strExplorer,
355 strNoCustomWebView,
356 SHELL_NO_POLICY
359 0x40000010,
360 strActiveDesk,
361 strNoHTMLWallpaper,
362 SHELL_NO_POLICY
365 0x40000011,
366 strActiveDesk,
367 strNoChangeWallpaper,
368 SHELL_NO_POLICY
371 0x40000012,
372 strActiveDesk,
373 strNoComponent,
374 SHELL_NO_POLICY
377 0x40000013,
378 strActiveDesk,
379 strNoAddComponent,
380 SHELL_NO_POLICY
383 0x40000014,
384 strActiveDesk,
385 strNoDelComponent,
386 SHELL_NO_POLICY
389 0x40000015,
390 strActiveDesk,
391 strNoCloseComponent,
392 SHELL_NO_POLICY
395 0x40000016,
396 strActiveDesk,
397 strNoCloseDragDrop,
398 SHELL_NO_POLICY
401 0x40000017,
402 strActiveDesk,
403 strNoMovingBand,
404 SHELL_NO_POLICY
407 0x40000018,
408 strActiveDesk,
409 strNoEditComponent,
410 SHELL_NO_POLICY
413 0x40000019,
414 strExplorer,
415 strNoResolveSearch,
416 SHELL_NO_POLICY
419 0x4000001a,
420 strExplorer,
421 strNoResolveTrk,
422 SHELL_NO_POLICY
425 0x4000001b,
426 strExplorer,
427 strForceCopyACLW,
428 SHELL_NO_POLICY
431 0x4000001c,
432 strExplorer,
433 strNoMSAppLogo,
434 SHELL_NO_POLICY
437 0x4000001d,
438 strExplorer,
439 strNoForgetSoftwareUpdate,
440 SHELL_NO_POLICY
443 0x4000001e,
444 strExplorer,
445 strNoSetActiveDesktop,
446 SHELL_NO_POLICY
449 0x4000001f,
450 strExplorer,
451 strNoWindowsUpdate,
452 SHELL_NO_POLICY
455 0x40000020,
456 strExplorer,
457 strNoChangeStartMenu,
458 SHELL_NO_POLICY
461 0x40000021,
462 strExplorer,
463 strNoFolderOptions,
464 SHELL_NO_POLICY
467 0x50000024,
468 strExplorer,
469 strNoFileURL,
470 SHELL_NO_POLICY
474 /*************************************************************************
475 * SHRestricted [SHELL32.100]
477 * walks through policy table, queries <app> key, <type> value, returns
478 * queried (DWORD) value, and caches it between called to SHInitRestricted
479 * to prevent unnecessary registry access.
481 * NOTES
482 * exported by ordinal
484 * REFERENCES:
485 * MS System Policy Editor
486 * 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
487 * "The Windows 95 Registry", by John Woram, 1996 MIS: Press
489 DWORD WINAPI SHRestricted (DWORD pol) {
490 char regstr[256];
491 HKEY xhkey;
492 DWORD retval, polidx, i, datsize = 4;
494 TRACE("(%08lx)\n",pol);
496 polidx = -1;
498 /* scan to see if we know this policy ID */
499 for (i = 0; i < SHELL_MAX_POLICIES; i++)
501 if (pol == sh32_policy_table[i].polflags)
503 polidx = i;
504 break;
508 if (polidx == -1)
510 /* we don't know this policy, return 0 */
511 TRACE("unknown policy: (%08lx)\n", pol);
512 return 0;
515 /* we have a known policy */
516 strcpy(regstr, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\");
517 strcat(regstr, sh32_policy_table[polidx].appstr);
519 /* first check if this policy has been cached, return it if so */
520 if (sh32_policy_table[polidx].cache != SHELL_NO_POLICY)
522 return sh32_policy_table[polidx].cache;
525 /* return 0 and don't set the cache if any registry errors occur */
526 retval = 0;
527 if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
529 if (RegQueryValueExA(xhkey, sh32_policy_table[polidx].keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
531 sh32_policy_table[polidx].cache = retval;
534 RegCloseKey(xhkey);
537 return retval;
540 /*************************************************************************
541 * SHInitRestricted [SHELL32.244]
543 * Win98+ by-ordinal only routine called by Explorer and MSIE 4 and 5.
544 * Inits the policy cache used by SHRestricted to avoid excess
545 * registry access.
547 * INPUTS
548 * Two inputs: one is a string or NULL. If non-NULL the pointer
549 * should point to a string containing the following exact text:
550 * "Software\Microsoft\Windows\CurrentVersion\Policies".
551 * The other input is unused.
553 * NOTES
554 * If the input is non-NULL and does not point to a string containing
555 * that exact text the routine will do nothing.
557 * If the text does match or the pointer is NULL, then the routine
558 * will init SHRestricted()'s policy cache to all 0xffffffff and
559 * returns 0xffffffff as well.
561 * I haven't yet run into anything calling this with inputs other than
562 * (NULL, NULL), so I may have the inputs reversed.
565 BOOL WINAPI SHInitRestricted(LPSTR inpRegKey, LPSTR parm2)
567 int i;
569 TRACE("(%p, %p)\n", inpRegKey, parm2);
571 /* first check - if input is non-NULL and points to the secret
572 key string, then pass. Otherwise return 0.
575 if (inpRegKey != (LPSTR)NULL)
577 if (lstrcmpiA(inpRegKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies"))
579 /* doesn't match, fail */
580 return 0;
584 /* check passed, init all policy cache entries with SHELL_NO_POLICY */
585 for (i = 0; i < SHELL_MAX_POLICIES; i++)
587 sh32_policy_table[i].cache = SHELL_NO_POLICY;
590 return SHELL_NO_POLICY;