gpt4 book ai didi

autoit - 如何在 AutoIt 中找到复制失败的原因?

转载 作者:行者123 更新时间:2023-12-03 17:37:57 26 4
gpt4 key购买 nike

AutoIt FileCopy method定义以下返回值:

Return Value

Success: 1.
Failure: 0.



显然,当文件复制操作失败时,我想告诉用户失败的原因。我如何获得这些信息?

最佳答案

编辑:带有消息输出的重写函数(最后一个错误不适用于 au3 filecopy)

ConsoleWrite(copyFile("./ft", "./tg8"))


Func copyFile($source, $dest)

$ret = DllCall("kernel32.dll", "int", _
"CopyFileEx", _ ; W
"str", $source, _
"str", $dest, _
"ptr", Null, _ ;no callback
"str", Null, _
"int", 0, _
"int", 0)

Return _GetLastErrorFormatMessage()

EndFunc ;==>copyFile



Func _GetLastErrorFormatMessage()
Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
Local $ret = ""
Local $message = ""
Local $err = ""
Local $buff = DllStructCreate("char[4096]")

$err = DllCall("Kernel32.dll", "int", "GetLastError")
$ret = DllCall("kernel32.dll", "int", "FormatMessage", _
"int", $FORMAT_MESSAGE_FROM_SYSTEM, _
"ptr", 0, _
"int", $err[0], _
"int", 0, _
"ptr", DllStructGetPtr($buff), _
"int", 4096, _
"ptr", 0)
$message = DllStructGetData($buff, 1)
$buff = Null
Return $message
EndFunc ;==>_GetLastErrorFormatMessage

关于autoit - 如何在 AutoIt 中找到复制失败的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38913130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com