找回密码
 加入
搜索
查看: 2021|回复: 3

将同一个文件下快捷方式信息收集到ini文件中,遇到障碍~~~请求帮助

[复制链接]
发表于 2008-5-20 19:07:36 | 显示全部楼层 |阅读模式
是这样的,同一个文件下有些快捷方式,我想用FileGetShortcut将所有的快捷方式的信息收集起来,并写入到ini文件.

下面走到FileGetShortcut时老是出不来结果,请求帮助...
提示MsgBox(0, "Path:", $details[0])出错...

$search = FileFindFirstFile("*.lnk")  
dim $details
If $search = -1 Then
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
EndIf
While 1
        $file = FileFindNextFile($search) 
        If @error Then ExitLoop
        $a=StringTrimRight ( $file, 4);文件名---[字段名]
$details = FileGetShortcut($search)
MsgBox(0, "Path:", $details[0])
WEnd
; Close the search handle
FileClose($search)


[ 本帖最后由 木纳 于 2008-5-20 19:21 编辑 ]
发表于 2008-5-20 19:17:03 | 显示全部楼层
原帖由 木纳 于 2008-5-20 19:07 发表
是这样的,同一个文件下有些快捷方式,我想用FileGetShortcut将所有的快捷方式的信息收集起来,并写入到ini文件.

下面走到FileGetShortcut时老是出不来结果,请求帮助...
提示MsgBox(0, "Path:", $details[0])出错 ...

$search = FileFindFirstFile("*.lnk")  
dim $details
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf
While 1
    $file = FileFindNextFile($search) 
    If @error Then 
        ExitLoop
        endif 
        $a=StringTrimRight ( $file, 4);文件名---[字段名]
$details = FileGetShortcut($file)
MsgBox(0, "Path:", $details[0])
WEnd
FileClose($search)

评分

参与人数 1贡献 +1 收起 理由
木纳 + 1 晕。。$file和$seach,自己看糊涂了. 谢谢

查看全部评分

 楼主| 发表于 2008-5-20 19:56:28 | 显示全部楼层
在大家的帮助下,算是能基本弄出来,

把学习结果晒晒,高手继续指给点指点~~

$search = FileFindFirstFile("*.lnk")
Dim $details
If $search = -1 Then
        MsgBox(0, "Error", "No files/directories matched the search pattern")
        Exit
EndIf
While 1
        $file = FileFindNextFile($search)
        If @error Then
                ExitLoop
        EndIf
        $a = StringTrimRight($file, 4);文件名---[字段名]
        $details = FileGetShortcut($file)
        IniWrite("练习.ini", $a, "本地目录", $details[1])
    sleep(50)
        IniWrite("练习.ini", $a, "执行文件", StringTrimLeft(StringReplace($details[0], $details[1], ""), 1))
    sleep(50)
WEnd
FileClose($search)
 楼主| 发表于 2008-5-25 20:41:51 | 显示全部楼层
上面那个搜索当前文件夹下的,继续贴了好收藏一下.
(俺是新人,学习的)
下面这个是搜索当前文件下指定文件夹内的lnk。就是另一个文件夹下的吧



$sPath = @ScriptDir & "\lnk"

$search = FileFindFirstFile($sPath & "\*.lnk")
If $search = -1 Then
        $sPath = @ScriptDir & "\lnk"
        $search = FileFindFirstFile($sPath & "\*.lnk")
        If $search = -1 Then
                MsgBox(0, "错误", "指定的文件下没有你要搜索的快捷方式文件")
                Exit
        EndIf
EndIf
While 1
        $string1 = $sPath & "\" & FileFindNextFile($search)
        $string2 = FileGetShortcut($string1)
        If @error Then
                MsgBox(0, "搜索完了,返回错误号", "@errot = " & @error)
                Exit
        EndIf

        $filename = StringTrimRight(StringTrimLeft(StringRight($string1, (StringLen($string1) - StringLen($sPath))), 1), 4)
        $runname = StringTrimLeft(StringRight($string2[0], (StringLen($string2[0]) - StringLen($string2[1]))), 1)
        IniWrite(@ScriptDir & "\练习.ini", $filename, "工作目录", $string2[1])
        Sleep(5)
        IniWrite(@ScriptDir & "\练习.ini", $filename, "执行文件", $runname)
        Sleep(5)
WEnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 16:59 , Processed in 0.079902 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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