45 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| unit cde_dir;
 | |
| {$mode delphi}
 | |
| {$codepage UTF8}
 | |
| interface
 | |
| uses LazFileUtils, sysutils, windows, shlobj, ANBFormatString, LazUTF8, cde_types;
 | |
| {stdcalls}
 | |
| function GetCDEPath: String; STDCALL;
 | |
| function ExpandPath(const Path: String): String; STDCALL;
 | |
| implementation
 | |
| function GetCDEPath: String;
 | |
| begin
 | |
| SetCurrentDirUTF8(ExtractFilePath(ParamStr(0)));
 | |
| SetCurrentDirUTF8('..\');
 | |
| Result:= IncludeTrailingBackslash(GetCurrentDirUTF8);
 | |
| end;
 | |
| function GetSpecialPath(const CSIDL: Word): String;
 | |
| var s: String;
 | |
| begin
 | |
| SetLength(s, MAX_PATH);
 | |
| if not SHGetSpecialFolderPath(0, PChar(s), CSIDL, True) then
 | |
|  s:= '';
 | |
| Result:= s;
 | |
| end;
 | |
| function ExpandPath(const Path: String): String;
 | |
| begin
 | |
| Result:= SysToUTF8(FormatStr(Path,
 | |
|                                   [
 | |
|                                    pth_windir,
 | |
|                                    pth_windisc,
 | |
|                                    pth_desktop,
 | |
|                                    pth_personal,
 | |
|                                    pth_fonts,
 | |
|                                    pth_wappdata
 | |
|                                   ],
 | |
|                                   [
 | |
|                                    IncludeTrailingBackslash(GetSpecialPath(CSIDL_WINDOWS)),
 | |
|                                    PChar(GetSpecialPath(CSIDL_WINDOWS))[0] + ':\',
 | |
|                                    IncludeTrailingBackslash(GetSpecialPath(CSIDL_DESKTOP)),
 | |
|                                    IncludeTrailingBackslash(GetSpecialPath(CSIDL_PERSONAL)),
 | |
|                                    IncludeTrailingBackslash(GetSpecialPath(CSIDL_FONTS)),
 | |
|                                    IncludeTrailingBackslash(GetSpecialPath(CSIDL_APPDATA)),
 | |
|                                   ]));
 | |
| end;
 | |
| end.
 |