六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 55|回复: 0

在桌面上自动创建快捷方式

[复制链接]

升级  35.67%

93

主题

93

主题

93

主题

举人

Rank: 3Rank: 3

积分
307
 楼主| 发表于 2013-1-27 04:42:41 | 显示全部楼层 |阅读模式
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">uses   ShellAPI,   ShlObj,   ActiveX,   ComObj;   
    
  const   
          CCH_MAXNAME
=255;   
          LNK_RUN_MIN
=7;   
          LNK_RUN_MAX
=3;   
          LNK_RUN_NORMAL
=1;   
  type   
          LINK_FILE_INFO
=record   
                  FileName
:array[0..MAX_PATH]   of   char;   
                  WorkDirectory
:array[0..MAX_PATH]   of   char;   
                  IconLocation
:array[0..MAX_PATH]   of   char;   
                  IconIndex
:integer;   
                  Arguments
:array[0..MAX_PATH]   of   char;   
                  Description
:array[0..CCH_MAXNAME]   of   char;   
                  ItemIDList
:PItemIDList;   
                  RelativePath
:array[0..255]   of   char;   
                  ShowState
:integer;   
                  HotKey
:word;   
          end;   
    
  function   CreateLinkFile(const   info
:LINK_FILE_INFO;const   DestFileName:string=''):boolean;   
  var   
          anobj
:IUnknown;   
          shlink
:IShellLink;   
          pFile
:IPersistFile;   
          wFileName
:widestring;   
  begin   
          wFileName
:=destfilename;   
          anobj
:=CreateComObject(CLSID_SHELLLINK);   
          shlink
:=anobj   as   IShellLink;   
          pFile
:=anobj   as   IPersistFile;   
          shlink
.SetPath(info.FileName);   
          shlink
.SetWorkingDirectory(info.WorkDirectory);   
          shlink
.SetDescription(info.Description);   
          shlink
.SetArguments(info.Arguments);   
          shlink
.SetIconLocation(info.IconLocation,info.IconIndex);   
          shlink
.SetHotkey(info.HotKey);   
          shlink
.SetShowCmd(info.ShowState);   
          shlink
.SetRelativePath(info.RelativePath,0);   
          
if   DestFileName=''   then   
                  wFileName
:=ChangeFileExt(info.FileName,'lnk');   
          result
:=succeeded(pFile.Save(pwchar(wFileName),false));   
  end;   
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表