Files Delphi

Title: Get default a folder Path Location e.g my documents
Question: How to get default folder location eg.
My documents, Recycle bin, desktop, startup etc
Answer:
uses ShlObj, ActiveX
declare the function at public or private declaration
function GetDirectoryPath(Folder:Integer): string;
call this in your buttonclick
showmessage(GetDirectoryPath(Folder));
Replace folder with any of the following:
{
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
}
e.g showmessage(GetDirectoryPath (CSIDL_DESKTOP));
function TForm1.GetDirectoryPath(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;