bhffhzh 发表于 2014-7-1 22:12:26

au3  如何将长文件名转成 短文件名

诸如:

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个字符。
特提出讨论。

haijie1223 发表于 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))

haijie1223 发表于 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)

bhffhzh 发表于 2014-7-3 09:35:01

只读出了C:\DOCUME~1?

wangms 发表于 2014-7-4 09:56:51

帮顶学习。。。。。。。。。。。。。。。。。。

boyhong 发表于 2014-7-5 19:51:49

回复 1# bhffhzh MsgBox(0,"",FileGetShortName("C:\Program Files\Common Files"))如上用现成的,有什么问题么?请教~~

gplane 发表于 2014-7-7 10:28:13

回复 8# boyhong
假设c盘下有“program filesss”这样的目录,那么有filegetshortname函数就会得到错误结果(正确结果是progra~2。

boyhong 发表于 2014-7-8 19:30:56

回复boyhong
假设c盘下有“program filesss”这样的目录,那么有filegetshortname函数就会得到错误结果 ...
gplane 发表于 2014-7-7 10:28 http://61.153.183.105/images/common/back.gif


    您在一楼写的短文件名不就是8.3规则短文件名?
页: [1]
查看完整版本: au3  如何将长文件名转成 短文件名