RT ,API函数有SHGetPathFromIDList,SHBrowseForFolder 了  ,我现在想使用这些函数实现定位文件,并获取文件的全路径,应该怎么做,谁能教教我。。  在线等 急用!!!!!!或则有什么 好的方法的。。(最好也是API 函数,不要CommonDialog。#17 )

解决方案 »

  1.   

    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 Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long 
    Private Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long 
    Private Sub Form_Load() 
    Dim zmh1 As OPENFILENAME 
    With zmh1 
    .lStructSize = Len(zmh1) 
    .lpstrFile = String(255, 0) 
    .nMaxFile = 255 
    .lpstrFileTitle = String(255, 0) 
    .nMaxFileTitle = 255 
    End With 
    zmh2 = GetOpenFileName(zmh1) 
    file1 = Left$(zmh1.lpstrFile, zmh1.nMaxFile) 
    file1 = Replace(file1, Chr(0), "") 
    file2 = Left$(zmh1.lpstrFileTitle, zmh1.nMaxFileTitle) 
    file2 = Replace(file2, Chr(0), "") 
    MsgBox file1 & vbCrLf & file2 
    End Sub 
      

  2.   

    用API函数:GetFullPathName,或者VB提供的DIR函数均可。