Correct some PIDL types and eliminate some magic numbers in PIDL
[wine] / dlls / shell32 / shpolicy.c
1 /*
2  * shpolicy.c - Data for shell/system policies.
3  *
4  * Copyright 1999 Ian Schmidt <ischmidt@cfl.rr.com>
5  *
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.
10  *
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.
15  *
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
19  *
20  * NOTES:
21  *
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...
28  *
29  * Up to date as of SHELL32 v5.00 (W2K)
30  */
31
32 #include <stdarg.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 #include "windef.h"
37 #include "winbase.h"
38 #include "winerror.h"
39 #include "winreg.h"
40
41 #include "shell32_main.h"
42 #include "shlobj.h"
43
44 #include "wine/debug.h"
45
46 WINE_DEFAULT_DEBUG_CHANNEL(shell);
47
48 #define SHELL_NO_POLICY 0xffffffff
49
50 typedef struct tagPOLICYDAT
51 {
52   DWORD policy;          /* policy value passed to SHRestricted */
53   LPCSTR appstr;         /* application str such as "Explorer" */
54   LPCSTR keystr;         /* name of the actual registry key / policy */
55   DWORD cache;           /* cached value or 0xffffffff for invalid */
56 } POLICYDATA, *LPPOLICYDATA;
57
58 /* registry strings */
59 static const CHAR strRegistryPolicyA[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies";
60 static const WCHAR strRegistryPolicyW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o',
61                                            's','o','f','t','\\','W','i','n','d','o','w','s','\\',
62                                            'C','u','r','r','e','n','t','V','e','r','s','i','o','n',
63                                            '\\','P','o','l','i','c','i','e','s',0};
64 static const CHAR strPolicyA[] = "Policy";
65 static const WCHAR strPolicyW[] = {'P','o','l','i','c','y',0};
66
67 /* application strings */
68
69 static const char strExplorer[] = {"Explorer"};
70 static const char strActiveDesk[] = {"ActiveDesktop"};
71 static const char strWinOldApp[] = {"WinOldApp"};
72 static const char strAddRemoveProgs[] = {"AddRemoveProgs"};
73
74 /* key strings */
75
76 static const char strNoFileURL[] = {"NoFileUrl"};
77 static const char strNoFolderOptions[] = {"NoFolderOptions"};
78 static const char strNoChangeStartMenu[] = {"NoChangeStartMenu"};
79 static const char strNoWindowsUpdate[] = {"NoWindowsUpdate"};
80 static const char strNoSetActiveDesktop[] = {"NoSetActiveDesktop"};
81 static const char strNoForgetSoftwareUpdate[] = {"NoForgetSoftwareUpdate"};
82 static const char strNoMSAppLogo[] = {"NoMSAppLogo5ChannelNotify"};
83 static const char strForceCopyACLW[] = {"ForceCopyACLWithFile"};
84 static const char strNoResolveTrk[] = {"NoResolveTrack"};
85 static const char strNoResolveSearch[] = {"NoResolveSearch"};
86 static const char strNoEditComponent[] = {"NoEditingComponents"};
87 static const char strNoMovingBand[] = {"NoMovingBands"};
88 static const char strNoCloseDragDrop[] = {"NoCloseDragDropBands"};
89 static const char strNoCloseComponent[] = {"NoClosingComponents"};
90 static const char strNoDelComponent[] = {"NoDeletingComponents"};
91 static const char strNoAddComponent[] = {"NoAddingComponents"};
92 static const char strNoComponent[] = {"NoComponents"};
93 static const char strNoChangeWallpaper[] = {"NoChangingWallpaper"};
94 static const char strNoHTMLWallpaper[] = {"NoHTMLWallpaper"};
95 static const char strNoCustomWebView[] = {"NoCustomizeWebView"};
96 static const char strClassicShell[] = {"ClassicShell"};
97 static const char strClearRecentDocs[] = {"ClearRecentDocsOnExit"};
98 static const char strNoFavoritesMenu[] = {"NoFavoritesMenu"};
99 static const char strNoActiveDesktopChanges[] = {"NoActiveDesktopChanges"};
100 static const char strNoActiveDesktop[] = {"NoActiveDesktop"};
101 static const char strNoRecentDocMenu[] = {"NoRecentDocsMenu"};
102 static const char strNoRecentDocHistory[] = {"NoRecentDocsHistory"};
103 static const char strNoInetIcon[] = {"NoInternetIcon"};
104 static const char strNoSettingsWizard[] = {"NoSettingsWizards"};
105 static const char strNoLogoff[] = {"NoLogoff"};
106 static const char strNoNetConDis[] = {"NoNetConnectDisconnect"};
107 static const char strNoViewContextMenu[] = {"NoViewContextMenu"};
108 static const char strNoTrayContextMenu[] = {"NoTrayContextMenu"};
109 static const char strNoWebMenu[] = {"NoWebMenu"};
110 static const char strLnkResolveIgnoreLnkInfo[] = {"LinkResolveIgnoreLinkInfo"};
111 static const char strNoCommonGroups[] = {"NoCommonGroups"};
112 static const char strEnforceShlExtSecurity[] = {"EnforceShellExtensionSecurity"};
113 static const char strNoRealMode[] = {"NoRealMode"};
114 static const char strMyDocsOnNet[] = {"MyDocsOnNet"};
115 static const char strNoStartMenuSubfolder[] = {"NoStartMenuSubFolders"};
116 static const char strNoAddPrinters[] = {"NoAddPrinter"};
117 static const char strNoDeletePrinters[] = {"NoDeletePrinter"};
118 static const char strNoPrintTab[] = {"NoPrinterTabs"};
119 static const char strRestrictRun[] = {"RestrictRun"};
120 static const char strNoStartBanner[] = {"NoStartBanner"};
121 static const char strNoNetworkNeighborhood[] = {"NoNetHood"};
122 static const char strNoDriveTypeAtRun[] = {"NoDriveTypeAutoRun"};
123 static const char strNoDrivesAutoRun[] = {"NoDriveAutoRun"};
124 static const char strSeparateProcess[] = {"SeparateProcess"};
125 static const char strNoDrives[] = {"NoDrives"};
126 static const char strNoFind[] = {"NoFind"};
127 static const char strNoDesktop[] = {"NoDesktop"};
128 static const char strNoSetTaskBar[] = {"NoSetTaskbar"};
129 static const char strNoSetFld[] = {"NoSetFolders"};
130 static const char strNoFileMenu[] = {"NoFileMenu"};
131 static const char strNoSaveSetting[] = {"NoSaveSettings"};
132 static const char strNoClose[] = {"NoClose"};
133 static const char strNoRun[] = {"NoRun"};
134
135 /* policy data array */
136 POLICYDATA sh32_policy_table[] =
137 {
138   {
139     REST_NORUN,
140     strExplorer,
141     strNoRun,
142     SHELL_NO_POLICY
143   },
144   {
145     REST_NOCLOSE,
146     strExplorer,
147     strNoClose,
148     SHELL_NO_POLICY
149   },
150   {
151     REST_NOSAVESET,
152     strExplorer,
153     strNoSaveSetting,
154     SHELL_NO_POLICY
155   },
156   {
157     REST_NOFILEMENU,
158     strExplorer,
159     strNoFileMenu,
160     SHELL_NO_POLICY
161   },
162   {
163     REST_NOSETFOLDERS,
164     strExplorer,
165     strNoSetFld,
166     SHELL_NO_POLICY
167   },
168   {
169     REST_NOSETTASKBAR,
170     strExplorer,
171     strNoSetTaskBar,
172     SHELL_NO_POLICY
173   },
174   {
175     REST_NODESKTOP,
176     strExplorer,
177     strNoDesktop,
178     SHELL_NO_POLICY
179   },
180   {
181     REST_NOFIND,
182     strExplorer,
183     strNoFind,
184     SHELL_NO_POLICY
185   },
186   {
187     REST_NODRIVES,
188     strExplorer,
189     strNoDrives,
190     SHELL_NO_POLICY
191   },
192   {
193     REST_NODRIVEAUTORUN,
194     strExplorer,
195     strNoDrivesAutoRun,
196     SHELL_NO_POLICY
197   },
198   {
199     REST_NODRIVETYPEAUTORUN,
200     strExplorer,
201     strNoDriveTypeAtRun,
202     SHELL_NO_POLICY
203   },
204   {
205     REST_NONETHOOD,
206     strExplorer,
207     strNoNetworkNeighborhood,
208     SHELL_NO_POLICY
209   },
210   {
211     REST_STARTBANNER,
212     strExplorer,
213     strNoStartBanner,
214     SHELL_NO_POLICY
215   },
216   {
217     REST_RESTRICTRUN,
218     strExplorer,
219     strRestrictRun,
220     SHELL_NO_POLICY
221   },
222   {
223     REST_NOPRINTERTABS,
224     strExplorer,
225     strNoPrintTab,
226     SHELL_NO_POLICY
227   },
228   {
229     REST_NOPRINTERDELETE,
230     strExplorer,
231     strNoDeletePrinters,
232     SHELL_NO_POLICY
233   },
234   {
235     REST_NOPRINTERADD,
236     strExplorer,
237     strNoAddPrinters,
238     SHELL_NO_POLICY
239   },
240   {
241     REST_NOSTARTMENUSUBFOLDERS,
242     strExplorer,
243     strNoStartMenuSubfolder,
244     SHELL_NO_POLICY
245   },
246   {
247     REST_MYDOCSONNET,
248     strExplorer,
249     strMyDocsOnNet,
250     SHELL_NO_POLICY
251   },
252   {
253     REST_NOEXITTODOS,
254     strWinOldApp,
255     strNoRealMode,
256     SHELL_NO_POLICY
257   },
258   {
259     REST_ENFORCESHELLEXTSECURITY,
260     strExplorer,
261     strEnforceShlExtSecurity,
262     SHELL_NO_POLICY
263   },
264   {
265     REST_LINKRESOLVEIGNORELINKINFO,
266     strExplorer,
267     strLnkResolveIgnoreLnkInfo,
268     SHELL_NO_POLICY
269   },
270   {
271     REST_NOCOMMONGROUPS,
272     strExplorer,
273     strNoCommonGroups,
274     SHELL_NO_POLICY
275   },
276   {
277     REST_SEPARATEDESKTOPPROCESS,
278     strExplorer,
279     strSeparateProcess,
280     SHELL_NO_POLICY
281   },
282   {
283     REST_NOWEB,
284     strExplorer,
285     strNoWebMenu,
286     SHELL_NO_POLICY
287   },
288   {
289     REST_NOTRAYCONTEXTMENU,
290     strExplorer,
291     strNoTrayContextMenu,
292     SHELL_NO_POLICY
293   },
294   {
295     REST_NOVIEWCONTEXTMENU,
296     strExplorer,
297     strNoViewContextMenu,
298     SHELL_NO_POLICY
299   },
300   {
301     REST_NONETCONNECTDISCONNECT,
302     strExplorer,
303     strNoNetConDis,
304     SHELL_NO_POLICY
305   },
306   {
307     REST_STARTMENULOGOFF,
308     strExplorer,
309     strNoLogoff,
310     SHELL_NO_POLICY
311   },
312   {
313     REST_NOSETTINGSASSIST,
314     strExplorer,
315     strNoSettingsWizard,
316     SHELL_NO_POLICY
317   },
318   {
319     REST_NOINTERNETICON,
320     strExplorer,
321     strNoInetIcon,
322     SHELL_NO_POLICY
323   },
324   {
325     REST_NORECENTDOCSHISTORY,
326     strExplorer,
327     strNoRecentDocHistory,
328     SHELL_NO_POLICY
329   },
330   {
331     REST_NORECENTDOCSMENU,
332     strExplorer,
333     strNoRecentDocMenu,
334     SHELL_NO_POLICY
335   },
336   {
337     REST_NOACTIVEDESKTOP,
338     strExplorer,
339     strNoActiveDesktop,
340     SHELL_NO_POLICY
341   },
342   {
343     REST_NOACTIVEDESKTOPCHANGES,
344     strExplorer,
345     strNoActiveDesktopChanges,
346     SHELL_NO_POLICY
347   },
348   {
349     REST_NOFAVORITESMENU,
350     strExplorer,
351     strNoFavoritesMenu,
352     SHELL_NO_POLICY
353   },
354   {
355     REST_CLEARRECENTDOCSONEXIT,
356     strExplorer,
357     strClearRecentDocs,
358     SHELL_NO_POLICY
359   },
360   {
361     REST_CLASSICSHELL,
362     strExplorer,
363     strClassicShell,
364     SHELL_NO_POLICY
365   },
366   {
367     REST_NOCUSTOMIZEWEBVIEW,
368     strExplorer,
369     strNoCustomWebView,
370     SHELL_NO_POLICY
371   },
372   {
373     REST_NOHTMLWALLPAPER,
374     strActiveDesk,
375     strNoHTMLWallpaper,
376     SHELL_NO_POLICY
377   },
378   {
379     REST_NOCHANGINGWALLPAPER,
380     strActiveDesk,
381     strNoChangeWallpaper,
382     SHELL_NO_POLICY
383   },
384   {
385     REST_NODESKCOMP,
386     strActiveDesk,
387     strNoComponent,
388     SHELL_NO_POLICY
389   },
390   {
391     REST_NOADDDESKCOMP,
392     strActiveDesk,
393     strNoAddComponent,
394     SHELL_NO_POLICY
395   },
396   {
397     REST_NODELDESKCOMP,
398     strActiveDesk,
399     strNoDelComponent,
400     SHELL_NO_POLICY
401   },
402   {
403     REST_NOCLOSEDESKCOMP,
404     strActiveDesk,
405     strNoCloseComponent,
406     SHELL_NO_POLICY
407   },
408   {
409     REST_NOCLOSE_DRAGDROPBAND,
410     strActiveDesk,
411     strNoCloseDragDrop,
412     SHELL_NO_POLICY
413   },
414   {
415     REST_NOMOVINGBAND,
416     strActiveDesk,
417     strNoMovingBand,
418     SHELL_NO_POLICY
419   },
420   {
421     REST_NOEDITDESKCOMP,
422     strActiveDesk,
423     strNoEditComponent,
424     SHELL_NO_POLICY
425   },
426   {
427     REST_NORESOLVESEARCH,
428     strExplorer,
429     strNoResolveSearch,
430     SHELL_NO_POLICY
431   },
432   {
433     REST_NORESOLVETRACK,
434     strExplorer,
435     strNoResolveTrk,
436     SHELL_NO_POLICY
437   },
438   {
439     REST_FORCECOPYACLWITHFILE,
440     strExplorer,
441     strForceCopyACLW,
442     SHELL_NO_POLICY
443   },
444   {
445     REST_NOLOGO3CHANNELNOTIFY,
446     strExplorer,
447     strNoMSAppLogo,
448     SHELL_NO_POLICY
449   },
450   {
451     REST_NOFORGETSOFTWAREUPDATE,
452     strExplorer,
453     strNoForgetSoftwareUpdate,
454     SHELL_NO_POLICY
455   },
456   {
457     REST_NOSETACTIVEDESKTOP,
458     strExplorer,
459     strNoSetActiveDesktop,
460     SHELL_NO_POLICY
461   },
462   {
463     REST_NOUPDATEWINDOWS,
464     strExplorer,
465     strNoWindowsUpdate,
466     SHELL_NO_POLICY
467   },
468   {
469     REST_NOCHANGESTARMENU,
470     strExplorer,
471     strNoChangeStartMenu,
472     SHELL_NO_POLICY
473   },
474   {
475     REST_NOFOLDEROPTIONS,
476     strExplorer,
477     strNoFolderOptions,
478     SHELL_NO_POLICY
479   },
480   {
481     REST_HASFINDCOMPUTERS,
482     strExplorer,
483     "FindComputers",
484     SHELL_NO_POLICY
485   },
486   {
487     REST_INTELLIMENUS,
488     strExplorer,
489     "IntelliMenus",
490     SHELL_NO_POLICY
491   },
492   {
493     REST_RUNDLGMEMCHECKBOX,
494     strExplorer,
495     "MemCheckBoxInRunDlg",
496     SHELL_NO_POLICY
497   },
498   {
499     REST_ARP_ShowPostSetup,
500     strAddRemoveProgs,
501     "ShowPostSetup",
502     SHELL_NO_POLICY
503   },
504   {
505     REST_NOCSC,
506     strExplorer,
507     "NoSyncAll",
508     SHELL_NO_POLICY
509   },
510   {
511     REST_NOCONTROLPANEL,
512     strExplorer,
513     "NoControlPanel",
514     SHELL_NO_POLICY
515   },
516   {
517     REST_ENUMWORKGROUP,
518     strExplorer,
519     "EnumWorkgroup",
520     SHELL_NO_POLICY
521   },
522   {
523     REST_ARP_NOARP,
524     strAddRemoveProgs,
525     "NoAddRemovePrograms",
526     SHELL_NO_POLICY
527   },
528   {
529     REST_ARP_NOREMOVEPAGE,
530     strAddRemoveProgs,
531     "NoRemovePage",
532     SHELL_NO_POLICY
533   },
534   {
535     REST_ARP_NOADDPAGE,
536     strAddRemoveProgs,
537     "NoAddPage",
538     SHELL_NO_POLICY
539   },
540   {
541     REST_ARP_NOWINSETUPPAGE,
542     strAddRemoveProgs,
543     "NoWindowsSetupPage",
544     SHELL_NO_POLICY
545   },
546   {
547     REST_GREYMSIADS,
548     strExplorer,
549     "",
550     SHELL_NO_POLICY
551   },
552   {
553     REST_NOCHANGEMAPPEDDRIVELABEL,
554     strExplorer,
555     "NoChangeMappedDriveLabel",
556     SHELL_NO_POLICY
557   },
558   {
559     REST_NOCHANGEMAPPEDDRIVECOMMENT,
560     strExplorer,
561     "NoChangeMappedDriveComment",
562     SHELL_NO_POLICY
563   },
564   {
565     REST_MaxRecentDocs,
566     strExplorer,
567     "MaxRecentDocs",
568     SHELL_NO_POLICY
569   },
570   {
571     REST_NONETWORKCONNECTIONS,
572     strExplorer,
573     "NoNetworkConnections",
574     SHELL_NO_POLICY
575   },
576   {
577     REST_FORCESTARTMENULOGOFF,
578     strExplorer,
579     "ForceStartMenuLogoff",
580     SHELL_NO_POLICY
581   },
582   {
583     REST_NOWEBVIEW,
584     strExplorer,
585      "NoWebView",
586     SHELL_NO_POLICY
587   },
588   {
589     REST_NOCUSTOMIZETHISFOLDER,
590     strExplorer,
591     "NoCustomizeThisFolder",
592     SHELL_NO_POLICY
593   },
594   {
595     REST_NOENCRYPTION,
596     strExplorer,
597     "NoEncryption",
598     SHELL_NO_POLICY
599   },
600   {
601     REST_ALLOWFRENCHENCRYPTION,
602     strExplorer,
603     "AllowFrenchEncryption",
604     SHELL_NO_POLICY
605   },
606   {
607     REST_DONTSHOWSUPERHIDDEN,
608     strExplorer,
609     "DontShowSuperHidden",
610     SHELL_NO_POLICY
611   },
612   {
613     REST_NOSHELLSEARCHBUTTON,
614     strExplorer,
615     "NoShellSearchButton",
616     SHELL_NO_POLICY
617   },
618   {
619     REST_NOHARDWARETAB,
620     strExplorer,
621     "NoHardwareTab",
622     SHELL_NO_POLICY
623   },
624   {
625     REST_NORUNASINSTALLPROMPT,
626     strExplorer,
627     "NoRunasInstallPrompt",
628     SHELL_NO_POLICY
629   },
630   {
631     REST_PROMPTRUNASINSTALLNETPATH,
632     strExplorer,
633     "PromptRunasInstallNetPath",
634     SHELL_NO_POLICY
635   },
636   {
637     REST_NOMANAGEMYCOMPUTERVERB,
638     strExplorer,
639     "NoManageMyComputerVerb",
640     SHELL_NO_POLICY
641   },
642   {
643     REST_NORECENTDOCSNETHOOD,
644     strExplorer,
645     "NoRecentDocsNetHood",
646     SHELL_NO_POLICY
647   },
648   {
649     REST_DISALLOWRUN,
650     strExplorer,
651     "DisallowRun",
652     SHELL_NO_POLICY
653   },
654   {
655     REST_NOWELCOMESCREEN,
656     strExplorer,
657     "NoWelcomeScreen",
658     SHELL_NO_POLICY
659   },
660   {
661     REST_RESTRICTCPL,
662     strExplorer,
663     "RestrictCpl",
664     SHELL_NO_POLICY
665   },
666   {
667     REST_DISALLOWCPL,
668     strExplorer,
669     "DisallowCpl",
670     SHELL_NO_POLICY
671   },
672   {
673     REST_NOSMBALLOONTIP,
674     strExplorer,
675     "NoSMBalloonTip",
676     SHELL_NO_POLICY
677   },
678   {
679     REST_NOSMHELP,
680     strExplorer,
681     "NoSMHelp",
682     SHELL_NO_POLICY
683   },
684   {
685     REST_NOWINKEYS,
686     strExplorer,
687     "NoWinKeys",
688     SHELL_NO_POLICY
689   },
690   {
691     REST_NOENCRYPTONMOVE,
692     strExplorer,
693     "NoEncryptOnMove",
694     SHELL_NO_POLICY
695   },
696   {
697     REST_NOLOCALMACHINERUN,
698     strExplorer,
699     "DisableLocalMachineRun",
700     SHELL_NO_POLICY
701   },
702   {
703     REST_NOCURRENTUSERRUN,
704     strExplorer,
705     "DisableCurrentUserRun",
706     SHELL_NO_POLICY
707   },
708   {
709     REST_NOLOCALMACHINERUNONCE,
710     strExplorer,
711     "DisableLocalMachineRunOnce",
712     SHELL_NO_POLICY
713   },
714   {
715     REST_NOCURRENTUSERRUNONCE,
716     strExplorer,
717     "DisableCurrentUserRunOnce",
718     SHELL_NO_POLICY
719   },
720   {
721     REST_FORCEACTIVEDESKTOPON,
722     strExplorer,
723     "ForceActiveDesktopOn",
724     SHELL_NO_POLICY
725   },
726   {
727     REST_NOCOMPUTERSNEARME,
728     strExplorer,
729     "NoComputersNearMe",
730     SHELL_NO_POLICY
731   },
732   {
733     REST_NOVIEWONDRIVE,
734     strExplorer,
735     "NoViewOnDrive",
736     SHELL_NO_POLICY
737   },
738   {
739     REST_NONETCRAWL,
740     strExplorer,
741     "NoNetCrawl",
742     SHELL_NO_POLICY
743   },
744   {
745     REST_NOSHAREDDOCUMENTS,
746     strExplorer,
747     "NoSharedDocs",
748     SHELL_NO_POLICY
749   },
750   {
751     REST_NOSMMYDOCS,
752     strExplorer,
753     "NoSMMyDocs",
754     SHELL_NO_POLICY
755   },
756 /* 0x4000050 - 0x4000060 */
757   {
758     REST_STARTRUNNOHOMEPATH,
759     strExplorer,
760     "StartRunNoHOMEPATH",
761     SHELL_NO_POLICY
762   },
763 /* 0x4000061 - 0x4000086 */
764   {
765     REST_NODISCONNECT,
766     strExplorer,
767     "NoDisconnect",
768     SHELL_NO_POLICY
769   },
770   {
771     REST_NOSECURITY,
772     strExplorer,
773     "NoNTSecurity",
774     SHELL_NO_POLICY
775   },
776   {
777     REST_NOFILEASSOCIATE,
778     strExplorer,
779     "NoFileAssociate",
780     SHELL_NO_POLICY
781   },
782   {
783     0x50000024,
784     strExplorer,
785     strNoFileURL,
786     SHELL_NO_POLICY
787   },
788   {
789     0,
790     0,
791     0,
792     SHELL_NO_POLICY
793         }
794 };
795
796 /*************************************************************************
797  * SHRestricted                          [SHELL32.100]
798  *
799  * Get the value associated with a policy Id.
800  *
801  * PARAMS
802  *     pol [I] Policy Id
803  *
804  * RETURNS
805  *     The queried value for the policy.
806  *
807  * NOTES
808  *     Exported by ordinal.
809  *     This function caches the retrieved values to prevent unnecessary registry access,
810  *     if SHInitRestricted() was previously called.
811  *
812  * REFERENCES
813  *     a: MS System Policy Editor.
814  *     b: 98Lite 2.0 (which uses many of these policy keys) http://www.98lite.net/
815  *     c: 'The Windows 95 Registry', by John Woram, 1996 MIS: Press
816  */
817 DWORD WINAPI SHRestricted (RESTRICTIONS policy)
818 {
819         char regstr[256];
820         HKEY    xhkey;
821         DWORD   retval, datsize = 4;
822         LPPOLICYDATA p;
823
824         TRACE("(%08x)\n", policy);
825
826         /* scan to see if we know this policy ID */
827         for (p = sh32_policy_table; p->policy; p++)
828         {
829           if (policy == p->policy)
830           {
831             break;
832           }
833         }
834
835         if (p->policy == 0)
836         {
837             /* we don't know this policy, return 0 */
838             TRACE("unknown policy: (%08x)\n", policy);
839                 return 0;
840         }
841
842         /* we have a known policy */
843
844         /* first check if this policy has been cached, return it if so */
845         if (p->cache != SHELL_NO_POLICY)
846         {
847             return p->cache;
848         }
849
850         lstrcpyA(regstr, strRegistryPolicyA);
851         lstrcatA(regstr, p->appstr);
852
853         /* return 0 and don't set the cache if any registry errors occur */
854         retval = 0;
855         if (RegOpenKeyA(HKEY_CURRENT_USER, regstr, &xhkey) == ERROR_SUCCESS)
856         {
857           if (RegQueryValueExA(xhkey, p->keystr, NULL, NULL, (LPBYTE)&retval, &datsize) == ERROR_SUCCESS)
858           {
859             p->cache = retval;
860           }
861           RegCloseKey(xhkey);
862         }
863         return retval;
864 }
865
866 /*************************************************************************
867  * SHInitRestricted          [SHELL32.244]
868  *
869  * Initialise the policy cache to speed up calls to SHRestricted().
870  *
871  * PARAMS
872  *  unused    [I] Reserved.
873  *  inpRegKey [I] Registry key to scan.
874  *
875  * RETURNS
876  *  Success: -1. The policy cache is initialised.
877  *  Failure: 0, if inpRegKey is any value other than NULL, "Policy", or
878  *           "Software\Microsoft\Windows\CurrentVersion\Policies".
879  *
880  * NOTES
881  *  Exported by ordinal. Introduced in Win98.
882  */
883 BOOL WINAPI SHInitRestricted(LPCVOID unused, LPCVOID inpRegKey)
884 {
885         TRACE("(%p, %p)\n", unused, inpRegKey);
886
887         /* first check - if input is non-NULL and points to the secret
888            key string, then pass. Otherwise return 0.
889          */
890         if (inpRegKey != NULL)
891         {
892           if (SHELL_OsIsUnicode())
893           {
894             if (lstrcmpiW((LPWSTR)inpRegKey, strRegistryPolicyW) &&
895                 lstrcmpiW((LPWSTR)inpRegKey, strPolicyW))
896               /* doesn't match, fail */
897               return 0;
898           }
899           else
900           {
901             if (lstrcmpiA((LPSTR)inpRegKey, strRegistryPolicyA) &&
902                 lstrcmpiA((LPSTR)inpRegKey, strPolicyA))
903               /* doesn't match, fail */
904               return 0;
905           }
906         }
907
908         return TRUE;
909 }