在delphi中怎样从一个快捷方式(也就是*.lnk)中得到该快捷方式的可执行文件(100分)

  • 主题发起人 主题发起人 dmsm
  • 开始时间 开始时间
D

dmsm

Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi中怎样从一个快捷方式(也就是*.lnk)中得到该快捷方式的可执行文件<br>的全路径及文件名。<br>请各位大侠帮忙!!!非常感谢!!!<br>E-mail:dmsm@163.net
 
可以使用IShellLink和IPersistFile接口。Delphi帮助中有介绍。
 
咦? 又问! 下午才答了一次, 再PASTE一次吧:<br>procedure GetShellLinkInfo(const LinkFile: WideString; var SLI: TShellLinkInfo);<br>{ Retrieves information on an existing shell link }<br>var<br>&nbsp; SL: IShellLink;<br>&nbsp; PF: IPersistFile;<br>&nbsp; FindData: TWin32FindData;<br>&nbsp; AStr: array[0..MAX_PATH] of char;<br>begin<br>&nbsp; OleCheck(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER,<br>&nbsp; &nbsp; IShellLink, SL));<br>&nbsp; { The IShellLink implementer must also support the IPersistFile }<br>&nbsp; { interface. Get an interface pointer to it. }<br>&nbsp; PF := SL as IPersistFile;<br>&nbsp; { Load file into IPersistFile object }<br>&nbsp; OleCheck(PF.Load(PWideChar(LinkFile), STGM_READ));<br>&nbsp; { Resolve the link by calling the Resolve interface function. }<br>&nbsp; OleCheck(SL.Resolve(0, SLR_ANY_MATCH or SLR_NO_UI));<br>&nbsp; { Get all the info! }<br>&nbsp; with SLI do<br>&nbsp; begin<br>&nbsp; &nbsp; OleCheck(SL.GetPath(AStr, MAX_PATH, FindData, SLGP_SHORTPATH));<br>&nbsp; &nbsp; PathName := AStr;//文件名<br>&nbsp; &nbsp; OleCheck(SL.GetArguments(AStr, MAX_PATH));<br>&nbsp; &nbsp; Arguments := AStr;//参数<br>&nbsp; &nbsp; OleCheck(SL.GetDescription(AStr, MAX_PATH));<br>&nbsp; &nbsp; Description := AStr;//描述<br>&nbsp; &nbsp; OleCheck(SL.GetWorkingDirectory(AStr, MAX_PATH));<br>&nbsp; &nbsp; WorkingDirectory := AStr;//工作路径<br>&nbsp; &nbsp; OleCheck(SL.GetIconLocation(AStr, MAX_PATH, IconIndex));<br>&nbsp; &nbsp; IconLocation := AStr;//图标<br>&nbsp; &nbsp; OleCheck(SL.GetShowCmd(ShowCmd));<br>&nbsp; &nbsp; OleCheck(SL.GetHotKey(HotKey));//热键<br>&nbsp; end;<br>end;<br>
 
to xianjun :<br>我是初学者,请教如何调用
 
接受答案了.
 
后退
顶部