Mega Code Archive

 
Categories / Delphi / API
 

How to get destkop folder location

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShlObj, StdCtrls, FileCtrl; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; FileListBox1: TFileListBox; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var pItem: PItemIDList; Path: array [0..MAX_PATH-1] of char; begin {get location of destop folder} if SHGetSpecialFolderLocation(Handle, CSIDL_DESKTOP , pItem) = NOERROR then begin SHGetPathFromIDList(pItem, Path); FileListBox1.Directory:=path; // view files in the folder caption:=path; end; end; { Here is a list of Folder locations CSIDL_STARTMENU Start menu Folder location CSIDL_HISTORY History folder location CSIDL_INTERNET_CACHE Internet cache folder location CSIDL_COMMON_FAVORITES Favorates folder location CSIDL_PRINTHOOD Print Hood Folder Location CSIDL_COMMON_DESKTOPDIRECTORY Common Desktop folder location CSIDL_DESKTOP Desktop folder location CSIDL_RECENT Recent Folder Location CSIDL_PERSONAL My Documents folder location } end.