Create shortcuts to [start]

xiaoxiao2021-03-06  36

/ / According to Zswang and "Super Sweeping" partial function Adaptation // More than Put Function GetSpecialFolderDir (Const Folderid: Integer): string; var pIDL: PitemidList; buffer: array [0..255] of CHAR; Begin // Take the specified folder project table // csidl_startup: Start ShgetSpecialFolderLocation (Application.Handle, Folderid, PIDL); SHGETPATHFROMIDLIST (PIDL, Buffer); // Convert to file system RESULT: = StrPas (buffer) ;

function CreateShellLink (mPath: string; mWorkingDirectory: string; mFileName: WideString): Boolean; {return whether the creation of shortcut successful} var vShellLink: IShellLink; vPersistFile: IPersistFile; vUnKnown: IUnKnown; begin Result: = True; try vUnKnown: = CreateComObject (CLSID_ShellLink); vShellLink: = vUnKnown as IShellLink; vPersistFile: = vUnKnown as IPersistFile; vShellLink.SetPath (PChar (mPath)); vShellLink.SetWorkingDirectory (PChar (mWorkingDirectory)); if ExtractFileExt (mFileName) <> '.lnk' then MfileName: = mfilename '.Lnk'; vPersistFile.save (pwchar (mfilename), false; eXCEPT RESULT: = FALSE; END;

function CreateLinkToStartUp (AppName, WorkingDirectory, LinkFileName: String; CurrentUser: Boolean = True): Boolean; begin if CurrentUser then // CurrentUser Result: = CreateShellLink (AppName, WorkingDirectory, GetSpecialFolderDir (CSIDL_STARTUP) '/' LinkFileName) else // All user Result: = CreateShellLink (AppName, WorkingDirectory, GetSpecialFolderDir (CSIDL_COMMON_STARTUP) '/' LinkFileName); end; // create a current user of the [start], and finally a parameter CreateLinkToStartUp created all of True // In the user's boot, the last parameter in the CreateLinkTostArtUp is set to false // creation to other users, you can modify it, but. . . Don't do this. . .

转载请注明原文地址:https://www.9cbs.com/read-75698.html

New Post(0)