Mega Code Archive

 
Categories / Delphi / Files
 

How to get the Path to Program files

Title: How to get the Path to Program files uses Registry; function GetProgramFilesDir: string; var reg: TRegistry; begin reg := TRegistry.Create; try reg.RootKey := HKEY_LOCAL_MACHINE; reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion', False); Result := reg.ReadString('ProgramFilesDir'); finally reg.Free; end; end; procedure TForm1.Button1Click(Sender: TObject); begin // Shows something like c:\Program files ShowMessage(GetProgramFilesDir); end;