home *** CD-ROM | disk | FTP | other *** search
/ PC Administrator / spravce.iso / StartRight / source / UnitSpecialPaths.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-10-25  |  1.4 KB  |  59 lines

  1. unit UnitSpecialPaths;
  2. {
  3.     Purpose:
  4.         Return the paths to special folders used throught the program
  5. }
  6.  
  7. interface
  8.  
  9. type TSpecialPaths = class(TObject)
  10.     private
  11.         function GetPath(CLSIDL : word) : string;
  12.     public
  13.         function GetStartupPath : string;
  14.         function GetCommonStartupPath : string;
  15.         function GetAltStartupPath : string;
  16.         function GetStartRightStartup : string;
  17. end;
  18. var SpecialPaths : TSpecialPaths;
  19.  
  20. {////////////////////}
  21. {//}implementation{//}
  22. {////////////////////}
  23.  
  24. uses ShellAPI, ShlObj, Windows, Forms, SysUtils;
  25.  
  26. function TSpecialPaths.GetPath(CLSIDL : word) : string;
  27. var p : PItemIDList;
  28.     Path: array[0..MAX_PATH] of char;
  29. begin
  30.     SHGetSpecialFolderLocation(Application.Handle , CLSIDL, p);
  31.     SHGetPathFromIDList(p, path);
  32.     result := path;
  33. end;
  34.  
  35.  
  36. function TSpecialPaths.GetStartupPath : string;
  37. begin
  38.     result := self.GetPath(CSIDL_STARTUP);
  39. end;
  40.  
  41. function TSpecialPaths.GetCommonStartupPath : string;
  42. begin
  43.     result := self.GetPath(CSIDL_COMMON_STARTUP);
  44. end;
  45.  
  46. function TSpecialPaths.GetAltStartupPath : string;
  47. begin
  48.     result := self.GetPath(CSIDL_ALTSTARTUP);
  49. end;
  50. function TSpecialPaths.GetStartRightStartup : string;
  51. begin
  52.     result := IncludeTrailingPathDelimiter(
  53.          ExtractFilePath(Application.ExeName)) + 'Startup\';
  54. end;
  55.  
  56. initialization
  57.     SpecialPaths := TSpecialPaths.Create;
  58. end.
  59.