home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
StartRight
/
source.zip
/
UnitSpecialPaths.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2003-11-14
|
2KB
|
67 lines
unit UnitSpecialPaths;
{
Purpose:
Return the paths to special folders used throught the program
Updates:
Win9x compatibility added for GetCommonStartupPath
}
interface
type TSpecialPaths = class(TObject)
private
function GetPath(CLSIDL : word) : string;
public
function GetStartupPath : string;
function GetCommonStartupPath : string;
function GetAltStartupPath : string;
function GetStartRightStartup : string;
end;
var SpecialPaths : TSpecialPaths;
{////////////////////}
{//}implementation{//}
{////////////////////}
uses ShellAPI, ShlObj, Windows, Forms, SysUtils;
function TSpecialPaths.GetPath(CLSIDL : word) : string;
var p : PItemIDList;
Path: array[0..MAX_PATH] of char;
begin
SHGetSpecialFolderLocation(Application.Handle , CLSIDL, p);
SHGetPathFromIDList(p, path);
result := path;
end;
function TSpecialPaths.GetStartupPath : string;
begin
result := self.GetPath(CSIDL_STARTUP);
end;
function TSpecialPaths.GetCommonStartupPath : string;
begin
result := self.GetPath(CSIDL_COMMON_STARTUP);
// win9x compatibility
if (result = '') then begin
result := self.GetPath(CSIDL_STARTUP);
end;
end;
function TSpecialPaths.GetAltStartupPath : string;
begin
result := self.GetPath(CSIDL_ALTSTARTUP);
end;
function TSpecialPaths.GetStartRightStartup : string;
begin
result := IncludeTrailingPathDelimiter(
ExtractFilePath(Application.ExeName)) + 'Startup\';
end;
initialization
SpecialPaths := TSpecialPaths.Create;
end.