Mega Code Archive

 
Categories / Delphi / Examples
 

Startupfolder

> I want to programmatically add/remove a short cut from the StartUp folder. Does anyone know how to do this? Sure. There is a folder that contains the Start Menu (and all its user specific subfolders) On most Windows 9x computers this folder is "C:\Windows\Start Menu", but you can't count on that, esp. in NT. The best way to get the folder for the Start Menu is to use the API. Here's some code to get the Start Menu Folder: var MyITEMIDLIST: PITEMIDLIST; Path: String; begin SHGetSpecialFolderLocation(Form1.Handle,CSIDL_STARTMENU,MyITEMIDLIST); SetLength(Path,MAX_PATH); SHGetPathFromIDList(MyItemIDList,PChar(Path)); Path := Copy(Path,1,Pos(#0,Path)-1); ShowMessage(Path); end; {END CODE} This code displays the path to the start menu. You can get directly to the Start UP subfolder using the CSIDL_STARTUP value instead of CSIDL_STARTMENU. Many special folders can be found this way, check out the help in the WinAPI help on this. It may be harder to create a shortcut. You should look up Shell Links in the windows SDK help file to find out more about programmatically creating shortcuts. Hope this helps, Brad Dodson bdodson@dodson-hydro.com www.efloodmap.com/bdodson/