ASP.NET 直接呼叫系統內建的 comdlg32.dll ,省略對 comdlg32.ocx 的引用





Call dll


 Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" _
        (ByRef lpofn As OPENFILENAME) As Integer

    Structure OPENFILENAME
        Dim lStructSize As Integer
        Dim hwndOwner As Integer
        Dim hInstance As Integer
        Dim lpstrFilter As String
        Dim lpstrCustomFilter As String
        Dim nMaxCustomFilter As Integer
        Dim nFilterIndex As Integer
        Dim lpstrFile As String
        Dim nMaxFile As Integer
        Dim lpstrFileTitle As String
        Dim nMaxFileTitle As Integer
        Dim lpstrInitialDir As String
        Dim lpstrTitle As String
        Dim flags As Integer
        Dim nFileOffset As Short
        Dim nFileExtension As Short
        Dim lpstrDefExt As String
        Dim lCustData As Integer
        Dim lpfnHook As Integer
        Dim lpTemplateName As String
    End Structure

---------------------------------------------------------------
Apply


  Dim OFN As OPENFILENAME = Nothing
        With OFN
            .lStructSize = Len(OFN)
            .lpstrFile = Space(256) & vbNullChar
            .nMaxFile = Len(.lpstrFile)
            .flags = &H4 Or &H1000
            .lpstrFilter = "純文字檔" & Chr(0) & "*.txt" & Chr(0) & "HTML檔" & Chr(0) & "*.htm;*.html"
            .lpstrTitle = "GetFilePath"

            If GetOpenFileName(OFN) <> 0 Then
                TextBox2.Text = .lpstrFile
                'Microsoft.VisualBasic.Left(OFN.lpstrFile, InStr(OFN.lpstrFile, Chr(0)) - 1)
            End If
        End With

沒有留言:

張貼留言