Scalabium Software

SMExport/SMImport suites

Knowledge for your independence.
Home Delphi and C++Builder tips



#106:How can I read a path of system folder?

Just now in delphi-programming I posted a code which allows to recieve a path to some system folder (StartUp, Recent Files etc). As you know, the path can be different on other computers (depends from operationg system, localization, user profile and user settings).

This code allows to read a current value:

uses ShlObj, ActiveX;

function GetSystemPath(Folder: Integer): string;
var
  PIDL: PItemIDList;
  Path: LPSTR;
  AMalloc: IMalloc;
begin
  Path := StrAlloc(MAX_PATH);
  SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);
  if SHGetPathFromIDList(PIDL, Path) then
    Result := Path;
  SHGetMalloc(AMalloc);
  AMalloc.Free(PIDL);
  StrDispose(Path);
end;

Now you can call this function with different parameters. For example:
CSIDL_DESKTOP for WINDOWS\Desktop
CSIDL_DESKTOPDIRECTORY for WINDOWS\Desktop
CSIDL_FONTS for WINDOWS\FONTS
CSIDL_NETHOOD for WINDOWS\NetHood
CSIDL_PERSONAL for X:\My Documents
CSIDL_PROGRAMS for WINDOWS\StartMenu\Programs
CSIDL_RECENT for WINDOWS\Recent
CSIDL_SENDTO for WINDOWS\SendTo
CSIDL_STARTMENU for WINDOWS\Start Menu
CSIDL_STARTUP for WINDOWS\Start Menu\Programs\StartUp
CSIDL_TEMPLATES for WINDOWS\ShellNew

See also
 
ABA Document Convert
Viewer for TNEF-files (winmail.dat)
Clarion Viewer
MAPIMail
SMDBGrid
DBLoad
Paradox Password Recovery
Protected Storage Viewer
dBase Viewer
ABA Database Convert
 
 
Contact to webmaster

 

Are you crazy about technology? Are you interested in obtaining a career in web programming? There are many online college degrees in Information Technology, so you can live your desires. Locate an online degree as well as education grants to assist you.


Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2009, Scalabium Software. All rights reserved.
webmaster@scalabium.com

December 5, 2000

SMExport/SMImport suites