Mega Code Archive

 
Categories / Delphi / System
 

Get Windows startupfolder

Title: Get Windows startupfolder Question: How to use the shell-api to get the startup-folder ! Answer: function GetStartupFolderPath: String; var IIDList: PItemIDList; buffer: array [0..MAX_PATH-1] of char; begin IIDList:= nil; OleCheck(SHGetSpecialFolderLocation(Application.Handle, CSIDL_STARTUP {or CSIDL_COMMON_STARTUP},IIDList)); if not SHGetPathFromIDList(IIDList, buffer) then raise Exception.Create(''Could not get startup folder.''); Result:= StrPas(Buffer); end;