回复 7# netegg
不麻烦吧。下面是我试着写了个,可以实现返回值包含后缀,别的参数跟默认的一样用法
Func _FileSaveDialog($sTitle, $sInitDir, $sFilter='All (*.*)', $iOpt=0, $sDefFile='', $iDefFilter=1, $hWnd=0)
Local $iFileLen = 65536
Local $iFlag = BitOR(BitShift(BitAND($iOpt, 2), -10), BitShift(BitAND($iOpt, 16), 3))
If Not StringInStr($sFilter, '|') Then $sFilter &= '|*.*'
$sFilter = StringRegExpReplace($sFilter, '|+', '|')
Local $asFLines = StringSplit($sFilter, '|')
Local $i, $suFilter = ''
For $i = 1 To $asFLines[0] Step 2
If $i < $asFLines[0] Then _
$suFilter &= 'byte[' & StringLen($asFLines[$i]) + 1 & '];char[' & StringLen($asFLines[$i + 1]) + 1 & '];'
Next
Local $uOFN = DllStructCreate('dword;int;int;ptr;ptr;dword;dword;ptr;dword' & _
';ptr;int;ptr;ptr;dword;short;short;ptr;ptr;ptr;ptr;ptr;dword;dword')
Local $usTitle = DllStructCreate('char[' & StringLen($sTitle) + 1 & ']')
Local $usInitDir = DllStructCreate('char[' & StringLen($sInitDir) + 1 & ']')
Local $usFilter = DllStructCreate($suFilter & 'byte')
Local $usFile = DllStructCreate('char[' & $iFileLen & ']')
Local $usExtn = DllStructCreate('char[1]')
For $i = 1 To $asFLines[0]
DllStructSetData($usFilter, $i, $asFLines[$i])
Next
DllStructSetData($usTitle, 1, $sTitle)
DllStructSetData($usInitDir, 1, $sInitDir)
DllStructSetData($usFile, 1, $sDefFile)
DllStructSetData($usExtn, 1, '')
DllStructSetData($uOFN, 1, DllStructGetSize($uOFN))
DllStructSetData($uOFN, 2, $hWnd)
DllStructSetData($uOFN, 4, DllStructGetPtr($usFilter))
DllStructSetData($uOFN, 7, $iDefFilter)
DllStructSetData($uOFN, 8, DllStructGetPtr($usFile))
DllStructSetData($uOFN, 9, $iFileLen)
DllStructSetData($uOFN, 12, DllStructGetPtr($usInitDir))
DllStructSetData($uOFN, 13, DllStructGetPtr($usTitle))
DllStructSetData($uOFN, 14, $iFlag)
DllStructSetData($uOFN, 17, DllStructGetPtr($usExtn))
DllStructSetData($uOFN, 23, BitShift(BitAND($iOpt, 32), 5))
Local $aRet = DllCall('comdlg32.dll', 'int', 'GetSaveFileName', 'ptr', DllStructGetPtr($uOFN))
If Not IsArray($aRet) Or Not $aRet[0] Then Return SetError(1, 0, "")
Local $sRet = StringStripWS(DllStructGetData($usFile, 1), 3)
Return SetExtended(DllStructGetData($uOFN, 7), $sRet)
EndFunc
|