如何在桌面创建快捷方式

解决方案 »

  1.   


    uses     ComObj, ShlObj, ActiveX;
    Function CreateShortCutLink(Fname, LArguments, LinkPath, LDescription,StartDir, LinkIcon: string): HRESULT;var  IU: IUnknown;  ILink: IShellLink;  IPF: IPersistFile;  Buffer: array [0..MAX_PATH - 1] of Word;begin    IU := CreateComObject(CLSID_ShellLink);    ILink := IU as IShellLink;    IPF := IU as IPersistFile;    ILink.SetArguments(PChar(LArguments));    ILink.SetPath(PChar(Fname));    ILink.SetDescription(PChar(LDescription));    ILink.SetIconLocation(PChar(LinkIcon), 0);    ILink.SetWorkingDirectory(Pchar(StartDir));     MultiByteToWideChar(CP_ACP, 0, PChar(LinkPath), -1, @Buffer, MAX_PATH);    Result := IPF.Save(@Buffer, False);end;
    示例: 
         CreateShortCutLink(application.exename,'/ns','C:\windows\desktop\application.lnk','My application',application.exename);       * - This creates a shortcut named "Application.lnk" on the desktop with command line argumnets of "/ns" and the