找回密码
 加入
搜索
查看: 2661|回复: 8

如何清理桌面无效的快捷键

[复制链接]
发表于 2009-4-13 22:09:46 | 显示全部楼层 |阅读模式
本帖最后由 wjscxs 于 2010-5-29 05:12 编辑

求能够清理桌面无效快捷键的au3源码,能否用FileGetShortcut 实现???
发表于 2009-8-26 13:10:06 | 显示全部楼层
$aShoutcut = _filelisttoarray(@desktopcommdir & ".lnk")
for $i in $aShoutcut
    中间这段没找到相应函数,如何读取快捷方式目标
    if FileExists(上面的目标位置)=0 then
      filedelete()
    endif
next
发表于 2009-8-26 13:12:25 | 显示全部楼层
怎么判断这个shortcut icon是有效的呢
发表于 2009-8-26 13:19:27 | 显示全部楼层
你指的这个有效是什么意思,不是寻找目标文件吗?
发表于 2009-8-26 13:20:10 | 显示全部楼层
$search = FileFindFirstFile(@DesktopDir & "\*.lnk")
While 1
        $file = FileFindNextFile($search)
        $cut = FileGetShortcut(@DesktopDir & '\' & $file)
        If @error Then ExitLoop
        If FileExists($cut[0]) = 0 Then
                FileDelete(@DesktopDir & '\' & $file)
        EndIf
WEnd
FileClose($search)
发表于 2009-8-26 13:27:17 | 显示全部楼层
本帖最后由 netegg 于 2009-8-26 13:29 编辑

要不这样,
$file= ""
shellexecute($file)
if @error then filedelete($file)
不过这样有一点不好,要把快捷方式对应的程序,都启动一遍
发表于 2009-8-26 13:41:17 | 显示全部楼层
稍等等,已经求助了,我对api不是很熟,不过印象中好像有这个函数
发表于 2009-8-26 19:29:06 | 显示全部楼层
5楼代码可用。FileGetShortcut返回快捷方式内容,检查目标文件是否存在。

#include <File.au3>

CheckLnk(@DesktopCommonDir)
CheckLnk(@DesktopDir)
Exit

Func CheckLnk($sPath)
        Local $aLnkList, $aLnkInfo

        $aLnkList = _FileListToArray($sPath, "*.lnk", 1) ; 获取快捷方式列表
        If @error Then Return

        For $i = 1 To $aLnkList[0]
                $aLnkInfo = FileGetShortcut($sPath & "\" & $aLnkList[$i]) ; 获取快捷方式内容
                If NOT FileExists($aLnkInfo[0]) Then FileRecycle($sPath & "\" & $aLnkList[$i]) ; 目标文件不存在则删除
        Next

        Return 1
EndFunc   ;==>CheckLnk
发表于 2009-9-1 03:51:21 | 显示全部楼层
网蛋走进了误区 越走越远
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 21:25 , Processed in 0.077161 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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