Robert Meek wrote: > Below is the code from a unit I wanted to use to create a shortcut > to my application. I want the shortcut to be placed in the personal startup > folder of the currently logged on username. For some reason it's not > working.
You should know by now that "not working" is a lousy description of the problem. What happens? > But if I add the InFolder var to my LinkName var, as in: LinkName > := InFolder + JustNameL(TargetName) + '.lnk'; a shortcut does get placed in > the proper directory, but instead of the shortcut pointing to the exename, > it points to the entire folder path that the exename resides in! At what point in the code do you tell the shortcut that it should point at the EXE name and not the entire folder path? > begin > IObject := CreateComObject(CLSID_ShellLink); > ISLink := IObject as IShellLink; > IPFile := IObject as IPersistFile; > > with ISLink do begin > SetPath(pChar(AppPath)); > SetWorkingDirectory > (pChar(AppPath)); > end; Those lines set two fields of the shortcut object to refer to the application's path + '\'. > // if we want to place a link in a special folder > SHGetSpecialFolderLocation(0, CSIDL_STARTUP, PIDL); > SHGetPathFromIDList(PIDL, InFolder); If you're going to use ShGetSpecialFolderLocation instead of ShGetSpecialFolderPath, you need to remember to free the PIDL when you're finished with it. For example: http://www.cs.wisc.edu/~rkennedy/my-documents > TargetName := Application.ExeName; > LinkName := JustNameL(TargetName) + '.lnk'; > IPFile.Save(PWideChar(LinkName), True); That saves the shortcut object to a particular file. -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

