找回密码
 加入
搜索
查看: 5102|回复: 7

[效率算法] au3  如何将长文件名转成 短文件名

  [复制链接]
发表于 2014-7-1 22:12:26 | 显示全部楼层 |阅读模式
诸如:

c:\Documents and Settings\Administrator\AppData\Local\Application Data\Application Data\Application Data\Application Data\Application Data\     

C:\DOCUME~1\ADMINI~1\AppData\Local\APPLIC~1\APPLIC~1\APPLIC~1\APPLIC~1\APPLIC~1\


很多程序都无法突破255个字符。
特提出讨论。
发表于 2014-7-2 22:24:21 | 显示全部楼层
XP下测试的话,必须用有效的路径。
Dim $lShortPath
Dim $lLongPath="C:\Documents and Settings\Administrator\Application Data"

Dim $iLongPathLength=StringLen($lLongPath)
$iLongPathLength+=1
Dim $tLongPath=DllStructCreate("wchar["&$iLongPathLength&"]")
Dim $pLongPath=DllStructGetPtr($tLongPath)
DllStructSetData($tLongPath,1,$lLongPath)

Dim $iShortPathLength=StringLen($lLongPath)
$iShortPathLength+=1
Dim $tShortPath=DllStructCreate("wchar["&$iShortPathLength&"]")
Dim $pShortPath=DllStructGetPtr($tShortPath)


Dim $iResult=DllCall("Kernel32.dll","DWORD","GetShortPathNameW","ptr",$pLongPath,"ptr",$pShortPath,"DWORD",$iShortPathLength)
MsgBox(0,"",DllStructGetData($tShortPath,1))
发表于 2014-7-2 23:12:39 | 显示全部楼层
Dim $lLongPath="C:\Documents and Settings\Administrator\Application Data"
Dim $iResult = DllCall("kernel32.dll","long","GetShortPathNameW","wstr",$lLongPath,"wstr","","long",StringLen($lLongPath)+1)
If Not @error Then MsgBox(0,"",$iResult[2])
 楼主| 发表于 2014-7-3 09:35:01 | 显示全部楼层
只读出了C:\DOCUME~1?
发表于 2014-7-4 09:56:51 | 显示全部楼层
帮顶学习。。。。。。。。。。。。。。。。。。
发表于 2014-7-5 19:51:49 | 显示全部楼层
回复 1# bhffhzh
MsgBox(0,"",FileGetShortName("C:\Program Files\Common Files"))
如上用现成的,有什么问题么?请教~~
发表于 2014-7-7 10:28:13 | 显示全部楼层
回复 8# boyhong
假设c盘下有“program filesss”这样的目录,那么有filegetshortname函数就会得到错误结果(正确结果是progra~2。
发表于 2014-7-8 19:30:56 | 显示全部楼层
回复  boyhong
假设c盘下有“program filesss”这样的目录,那么有filegetshortname函数就会得到错误结果 ...
gplane 发表于 2014-7-7 10:28



    您在一楼写的短文件名不就是8.3规则短文件名?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-6 12:39 , Processed in 0.078239 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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