以下是引用片段: Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type '======================================= '打开一个文件 '======================================= Function GetFile(ByVal Hwnd As Long, Optional ByVal dlgFilter As String = "所有文件(*.*)|*.*", _ Optional ByVal dlgTitle As String = "打开文件", Optional ByVal DefaultDir) As String Dim ofn As OPENFILENAME Dim Rtn As String Dim fn(0) As String ofn.lStructSize = Len(ofn) ofn.hwndOwner = Hwnd ofn.hInstance = App.hInstance ofn.lpstrFile = String(254, Chr(0)) ofn.nMaxFile = 255 ofn.lpstrFileTitle = String(254, Chr(0)) ofn.nMaxFileTitle = 255 ofn.lpstrFilter = ChangeStr(dlgFilter) & Chr(0) ofn.lpstrTitle = dlgTitle If IsMissing(DefaultDir) Then ofn.lpstrInitialDir = App.Path Else ofn.lpstrInitialDir = DefaultDir End If ofn.flags = &H80000 'Or &H20 Rtn = GetOpenFileName(ofn) If Rtn >= 1 Then GetFile = Left(ofn.lpstrFile, InStr(1, ofn.lpstrFile, Chr(0)) - 1) Else GetFile = "" End If End Function '======================================= '打开多个文件,返回一个字符串数组 '======================================= Function GetFiles(ByVal Hwnd As Long, Optional ByVal dlgFilter As String = "所有文件(*.*)|*.*", _ Optional ByVal dlgTitle As String = "打开文件", Optional ByVal DefaultDir) As String() Dim ofn As OPENFILENAME Dim Rtn As Long Dim fn(0) As String ofn.lStructSize = Len(ofn) ofn.hwndOwner = Hwnd ofn.hInstance = App.hInstance ofn.lpstrFile = String(2000, Chr(0)) ofn.nMaxFile = 2000 ofn.lpstrFileTitle = String(254, Chr(0)) ofn.nMaxFileTitle = 255 ofn.lpstrFilter = ChangeStr(dlgFilter) & Chr(0) ofn.lpstrTitle = dlgTitle If IsMissing(DefaultDir) Then ofn.lpstrInitialDir = App.Path Else ofn.lpstrInitialDir = DefaultDir End If ofn.flags = &H80000 or &H200 'Or &H20 Rtn = GetOpenFileName(ofn) If Rtn >= 1 Then GetFiles = GetFileNames(ofn.lpstrFile) Else GetFiles = fn End If End Function '======================================= '保存文件 '======================================= Function SaveFile(ByVal Hwnd As Long, ByVal dlgFilterDescribe As String, ByVal dlgFilter As String, _ Optional ByVal dlgTitle As String = "保存文件", Optional ByVal dlgIniDir) As String Dim OFName As OPENFILENAME With OFName '设置结构的大小 .lStructSize = Len(OFName) '设置父窗口 .hwndOwner = Hwnd '设置程序的实例 .hInstance = App.hInstance '设置过滤属性 .lpstrFilter = dlgFilterDescribe & "(*" & dlgFilter & ")" & Chr(0) & "*" & dlgFilter & Chr(0) '设置默认扩展名 .lpstrFile = String(254, Chr(0)) '设置返回的文件(全路径)的最大长度 .nMaxFile = 255 '为文件名称创建缓冲区 .lpstrFileTitle = String(254, Chr(0)) '设置返回的文件名称的最大长度 .nMaxFileTitle = 255 '设置初始目录 If IsMissing(sIniDir) Then .lpstrInitialDir = App.Path Else .lpstrInitialDir = sIniDir End If '设置对话框标题 .lpstrTitle = sTitle .flags = &H80000 'Or &H20 End With If GetSaveFileName(OFName) Then SaveFile = Left(OFName.lpstrFile, InStr(1, OFName.lpstrFile, Chr(0)) - 1) & Trim(dlgFilter) Else SaveFile = "" End If End Function Private Function ChangeStr(ByVal strIn As String) As String ChangeStr = Replace(strIn, "|", Chr(0)) End Function Private Function GetFileNames(ByVal strIn As String) As String() Dim ln As Long, num As Integer, strPath As String, strName As String Dim pos() As Long, fn() As String ReDim pos(0) pos(0) = 1 strIn = Trim(strIn) ln = Len(strIn) For i = 1 To ln If Asc(Mid(strIn, i)) = 0 Then num = num + 1 ReDim Preserve pos(num) pos(num) = i If Asc(Mid(strIn, i + 1)) = 0 Then Exit For End If Next If num = 1 Then ReDim fn(0) fn(0) = Left(strIn, pos(1)) Else num = num - 2 ReDim fn(num) strPath = Left(strIn, pos(1) - 1) For i = 0 To num fn(i) = strPath & "\" & Mid(strIn, pos(i + 1) + 1, pos(i + 2) - pos(i + 1)) Next End If GetFileNames = fn End Function |
以下是引用片段: .Flags=cdlOFNAllowMultiselect |
From:http://topic.csdn.net/t/20050811/14/4203000.html
恩,按照你的方法成功解决乱码
@echo off都没有解释为什要有这个 还有后面的那个*。bat
怎么没有一个回首页的连接···[face09]
你是转载高手吗?
这是叠罗汉么? 随便就往上面放。。。。。 一点规律都没有就上面写了四类···· 哎 年轻人哪
里面的东西不能自动换行。看起来真郁闷。。[face12]
从别的地方转载的,你爱看就看,不爱看也没了[face62]
[face78] 太多了前面要先有个目录···· 累、
[face78]无聊! 注册了有什么用啊 应该还没有人注册····