• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 132
  • Last Modified:

GetOpenFileName in NT

I'm using API to show the Open File... common dialog box. It works fine in Win95/98 but it does nothing on Win NT?
This is my code:


'-----------------------------------
Public Function OpenFileDlg(hWndParent As Long, sFilter As String, sTitle As String, sInitDir As String, lpszFileNameBuf As String, bMustExist As Boolean, Optional sDefExt) As Boolean
    Dim ofn As OPENFILENAME
    Dim sFileName As String
    Dim i As Integer
   
    sFileName = Space(255)
   
'    sInitDir = Space(255)
'    Call GetWindowsDirectory(sInitDir, Len(sInitDir))
    With ofn
        .lStructSize = Len(ofn)
        .hwndOwner = hWndParent
        .hInstance = App.hInstance
        .lpstrFilter = sFilter
        '.lpstrCustomFilter
        '.nMaxCustFilter
        .nFilterIndex = 1
        .lpstrFile = sFileName
        .nMaxFile = Len(sFileName)
        '.lpstrFileTitle
        '.nMaxFileTitle
        .lpstrInitialDir = Trim(sInitDir)
        .lpstrTitle = sTitle
        .FLAGS = OFN_EXPLORER Or OFN_HIDEREADONLY Or OFN_LONGNAMES Or OFN_PATHMUSTEXIST
        If bMustExist Then
            .FLAGS = .FLAGS Or OFN_FILEMUSTEXIST
        End If
        '.nFileOffset
        '.nFileExtension
        If Not IsMissing(sDefExt) Then
            .lpstrDefExt = sDefExt
        End If
        '.lCustData
        '.lpfnHook
        '.lpTemplateName
    End With
    If (GetOpenFileName(ofn) = 0) Then  'OperaciĆ³n Cancelada
        OpenFileDlg = False
    Else
        OpenFileDlg = True
        lpszFileNameBuf = Trim(ofn.lpstrFile)
        i = InStr(1, lpszFileNameBuf, vbNullChar, vbBinaryCompare)
        If i > 0 Then
            lpszFileNameBuf = Trim(Left(lpszFileNameBuf, i - 1))
        Else
            lpszFileNameBuf = Trim(lpszFileNameBuf)
        End If
    End If
End Function
'-----------------------------------

What is wrong with this?

Thanks
0
trillo
Asked:
trillo
  • 2
  • 2
1 Solution
 
Erick37Commented:
Try running the example code from MS to see if it will run on your system.

http://support.microsoft.com/support/kb/articles/Q161/2/86.asp
0
 
trilloAuthor Commented:
Erick37: Please come back and say "hello" as an answer!!
0
 
Erick37Commented:
"Hello as an answer"
:-)
0
 
trilloAuthor Commented:
Fine!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now