咋样将指定文件夹里的文件发送到桌面快捷方式(代码)?
请大家帮帮忙,万分感谢!

解决方案 »

  1.   

    创建快捷方式的代码:
    procedure CreateShortcut(FileName : String; LinkFileName : String);
    Var
    LinkFile          : IPersistFile;
    ShellObject       : IUnknown;
    ShellLink         : IShellLink;FilePath,
    ShortcutPosition  : String;WShortcutPosition : WideString;
    P                 : PItemIDList;
    C                 : array[0..1000] of Char;
    begin
    CoInitialize(nil);
    Try
     ShellObject := CreateComObject(CLSID_ShellLink);
     LinkFile    := ShellObject as IPersistFile;
     ShellLink   := ShellObject as IShellLink; FilePath    := ExtractFilePath(Filename); ShellLink.SetPath(PChar(FileName));
     ShellLink.SetWorkingDirectory(PChar(FilePath));
     If SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOP, P) = NoError Then Begin
      SHGetPathFromIDList(P, C);
      ShortcutPosition  := StrPas(C);
      ShortcutPosition  := ShortcutPosition + '\' + LinkFileName;
      WShortcutPosition := ShortcutPosition;
      LinkFile.Save(PWChar(WShortcutPosition), False);
     End;
    finally
     CoUninitialize;
    end;
    end;
      

  2.   

    完整的代码:
    http://delphi.about.com/library/weekly/aa091499.htm