<pre class="code"><span class="key">const</span>
  cShellAppData = 'AppData'; 
  cShellCache = 'Cache'; 
  cShellCookies = 'Cookies'; 
  cShellDesktop = 'Desktop'; 
  cShellFavorites = 'Favorites'; 
  cShellFonts = 'Fonts'; 
  cShellHistory = 'History'; 
  cShellLocalApp = 'Local AppData'; 
  cShellNetHood = 'NetHood'; 
  cShellPersonal = 'Personal'; 
  cShellPrintHood = 'PrintHood'; 
  cShellPrograms = 'Programs'; 
  cShellRecent = 'Recent'; 
  cShellSendTo = 'SendTo'; 
  cShellStartMenu = 'Start Menu'; 
  cShellStartUp = 'Startup'; 
  cShellTemplates = 'Templates'; 

<span class="key">function</span> GetShellFolder (<span class="key">const</span> folder: <span class="key">string</span>):
<span class="key">string</span>;
<span class="key">const</span>
  cWin32 = 'SOFTWAREMicrosoftWindowsCurrentVersion';
  cSHellPrefix = 'ExplorerShell Folders'; 
<span class="key">var</span>
  reg: TRegistry; 
<span class="key">begin</span>
  Result:= ''; 
  reg:= TRegistry.Create; 
  <span class="key">try</span> 
    reg.Rootkey := 'HKEY_CURRENT_USER'; 
    // NTと95/98で違いはありません
    <span class="key">if</span> reg.OpenKey (cWin32 + cShellPrefix, false) <span class="key">then</span>
    <span class="key">begin</span>
      Result:= reg.ReadString(folder) + '';
    <span class="key">end</span>;
  <span class="key">finally</span>
    reg.Free;
  <span class="key">end</span>;
<span class="key">end</span>;
</pre>
<p>以下のように使用します。(Program Filesを取得する場合)</p>
<pre class="code">
  folder := GetShellFolder(cShellPrograms);
</pre>