将同一个文件下快捷方式信息收集到ini文件中,遇到障碍~~~请求帮助
是这样的,同一个文件下有些快捷方式,我想用FileGetShortcut将所有的快捷方式的信息收集起来,并写入到ini文件.下面走到FileGetShortcut时老是出不来结果,请求帮助...
提示MsgBox(0, "Path:", $details)出错...
$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)
WEnd
; Close the search handle
FileClose($search)
[ 本帖最后由 木纳 于 2008-5-20 19:21 编辑 ] 原帖由 木纳 于 2008-5-20 19:07 发表 http://www.autoitx.com/images/common/back.gif
是这样的,同一个文件下有些快捷方式,我想用FileGetShortcut将所有的快捷方式的信息收集起来,并写入到ini文件.
下面走到FileGetShortcut时老是出不来结果,请求帮助...
提示MsgBox(0, "Path:", $details)出错 ...
$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)
WEnd
FileClose($search) 在大家的帮助下,算是能基本弄出来,
把学习结果晒晒,高手继续指给点指点~~
$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)
sleep(50)
IniWrite("练习.ini", $a, "执行文件", StringTrimLeft(StringReplace($details, $details, ""), 1))
sleep(50)
WEnd
FileClose($search) 上面那个搜索当前文件夹下的,继续贴了好收藏一下.
(俺是新人,学习的)
下面这个是搜索当前文件下指定文件夹内的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, (StringLen($string2) - StringLen($string2))), 1)
IniWrite(@ScriptDir & "\练习.ini", $filename, "工作目录", $string2)
Sleep(5)
IniWrite(@ScriptDir & "\练习.ini", $filename, "执行文件", $runname)
Sleep(5)
WEnd
页:
[1]