how to get the startup folder path

eNarc
eNarc used Ask the Experts™
on
Hi, how do I get the Startup folder path of the current user and the local machine?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
uses ..., SysUtils, ShlObj;

function TmainF.GetAutorunFolder(val: Cardinal): String;
var
  Folder: array[0..255] of Char; //path to StartUp
  List: PitemidList; //list of "special" folders
begin
  SHGetSpecialFolderLocation(0, val, List);
  FillChar(Folder, SizeOf(Folder), 0);
  SHGetPathFromIDList(List, @Folder);
  Result := IncludeTrailingPathDelimiter(folder);
end;

GetAutorunFolder(CSIDL_COMMON_STARTUP)  //Give you StartUP folder for all users 

GetAutorunFolder(CSIDL_STARTUP) //Give you StartUP folder for current user 

Open in new window

Commented:
Try my code to get startup folder...
function GetStartUpFolder:string;
var
   FilePath: array [0..255] of char;
begin
 SHGetSpecialFolderPath(0,@FilePath[0],CSIDL_STARTUP,true);
 Result := FilePath;
end;

Open in new window

Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial