• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

File ListView control

Started by Eros Olmi, September 20, 2009, 08:30:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eros Olmi

Hi all,

I need a ListView file like control able to to list all files giving a full path. Files must have its own icon more or less like in standard open dialog control but without any directory.
Do you know if there is some code around I can check and adapt to my need?

Thanks a lot
Eros
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

Eros,

Of The Bay, is able to resolve the icon matching a specific file.

See also my C# project named zExplorer (that is also available in WinDev).

...

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Eros Olmi

Thanks Patrice but your C# example uses a .Net grid and functions to get icons are native to .Net framework.
I will see if I can create my own "listview file" list trying to simulate Explorer one.

Ciao
Eros
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

Eros,

Search in OTB for:

      DoIt = ExtractIconEx(lpszFile, -1, 0, 0, 0)
      IF DoIt THEN
         CALL ExtractIconEx(lpszFile, 0, hIconLarge, hIconSmall, 1)
         IF hIconLarge THEN
            CALL GetIconInfo(hIconLarge, ii)
         ELSE
            CALL GetIconInfo(hIconSmall, ii)
         END IF
      ELSE
         IsBatchFile = 2 '// Unknown icon
         lpszFile = "Unknown.png"
      END IF


Is that what you want to do?


(WD subclassed ListView)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Eros Olmi

Yes it is. Thanks I will check.

I've already done it but what is missing is icons: http://community.thinbasic.com/index.php?topic=2882.msg22184#msg22184 I will see what I can do.
Do you recognize anything there  :D    Thanks again for your zBFF dll.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Eros Olmi

Ok, thanks. More or less I've done it.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

I wonder what would be the size of zBff, if converted to PB9 (with new COM support).

I remember it has been a huge work to make it work with PB7.

By the way what is the size of the zBff.dll you are using?

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Eros Olmi

32.768 bytes dated  "1 dec 2006, 16.19.00"

I use it as a resource string loaded at runtime from memory and remapping exported functions.
So no dll on disk.

thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

Eros,

QuoteI use it as a resource string loaded at runtime from memory and remapping exported functions.
I do not know this technic (remapping exported functions).

...


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Edwin Knoppert

Sure, Semen's code to load a dll.
You are using it as well.

Eros Olmi

#10
Here an example and the needed code



In your RC file add something like this in order to save your DLL in RC file
RCZBFF RCDATA ".\\zBFF.dll"

Include the following in your application:
 ' ------- Additional API declarations ---------------
  %IMAGE_ORDINAL_FLAG                     = &H80000000

  Type IMAGE_IMPORT_BY_NAME
     Hint                   As Word
     ImpName                As Asciiz * 254
  End Type

  Type IMAGE_IMPORT_DESCRIPTOR
     OriginalFirstThunk     As Dword
     TimeDateStamp          As Dword
     ForwarderChain         As Dword
     pName                  As Dword
     FirstThunk             As Dword
  End Type

  Type IMAGE_BASE_RELOCATION
     VirtualAddress As Dword
     SizeOfBlock As Dword
  End Type

  '===========================================================================
  Declare Function EntryPoint(ByVal hInstance As Dword, ByVal Reason As Dword, ByVal Reserved As Dword) As Long

  Function GetProcAddressDirectly (ByVal lpImageDosHeader As IMAGE_DOS_HEADER Ptr, FuncName As Asciiz) As Dword
     Dim lpImageNtHeaders          As Local IMAGE_NT_HEADERS Ptr
     Dim lpImageExportDirectory    As Local IMAGE_EXPORT_DIRECTORY Ptr
     Dim lpNameOrdinals            As Local Word Ptr
     Dim lpFunctions               As Local Dword Ptr
     Dim lpExpFuncName             As Local Asciiz Ptr
     Dim lpName                    As Local Dword Ptr
     Dim lpFuncName                As Asciiz Ptr
     Dim i                         As Local Dword
     Dim j                         As Local Dword

     If @lpImageDosHeader.e_magic <> %IMAGE_DOS_SIGNATURE Then Function = 1: Exit Function ' invalid DOS signature
     lpImageNtHeaders = lpImageDosHeader + @lpImageDosHeader.e_lfanew
     If @lpImageNtHeaders.Signature <> %IMAGE_NT_SIGNATURE Then Function = 1: Exit Function ' invalid NT signature
     If @lpImageNtHeaders.FileHeader.SizeOfOptionalHeader <> SizeOf(@lpImageNtHeaders.OptionalHeader) Or _
        @lpImageNtHeaders.OptionalHeader.Magic <> %IMAGE_NT_OPTIONAL_HDR32_MAGIC Then Exit Function

     lpImageExportDirectory = @lpImageNtHeaders.OptionalHeader.DataDirectory(%IMAGE_DIRECTORY_ENTRY_EXPORT).VirtualAddress
     If lpImageExportDirectory = 0 Then Exit Function
     lpImageExportDirectory = lpImageExportDirectory + lpImageDosHeader

     lpNameOrdinals = @lpImageExportDirectory.AddressOfNameOrdinals + lpImageDosHeader
     lpName         = @lpImageExportDirectory.AddressOfNames        + lpImageDosHeader
     lpFunctions    = @lpImageExportDirectory.AddressOfFunctions    + lpImageDosHeader

     lpFuncName = VarPtr(FuncName)

     If HiWrd(lpFuncName) Then ' Name
        For i = 0 To @lpImageExportDirectory.NumberOfFunctions - 1
           If @lpFunctions[i] Then
              For j = 0 To @lpImageExportDirectory.NumberOfNames - 1
                 If @lpNameOrdinals[j] = i Then
                    lpExpFuncName = @lpName[j] + lpImageDosHeader
                    If @lpExpFuncName = FuncName Then Function = @lpFunctions[i] + lpImageDosHeader: Exit Function
                 End If
              Next
           End If
        Next
     Else
        For i = 0 To @lpImageExportDirectory.NumberOfFunctions - 1
           If lpFuncName = @lpImageExportDirectory.nBase + i Then
              If  @lpFunctions[i] Then Function = @lpFunctions[i] + lpImageDosHeader
              Exit Function
           End If
        Next
     End If
  End Function

  Function LoadPbDllFromMemory (ByVal lpRawDll As Dword, ByVal RawDllSize As Dword, lpImageDll As Dword) As Dword
     Dim sSysInfo                  As Local SYSTEM_INFO
     Dim ImagePages                As Local Dword
     Dim lpImageDosHeader          As Local IMAGE_DOS_HEADER Ptr
     Dim lpImageNtHeaders          As Local IMAGE_NT_HEADERS Ptr
     Dim lpImageSectionHeader      As Local IMAGE_SECTION_HEADER Ptr
     Dim lpImageImportDescriptor   As Local IMAGE_IMPORT_DESCRIPTOR Ptr
     Dim lpImageImportByName       As Local IMAGE_IMPORT_BY_NAME Ptr
     Dim lpImageBaseRelocTable     As Local IMAGE_BASE_RELOCATION Ptr
     Dim lpDllName                 As Local Asciiz Ptr
     Dim szDllName                 As Local String
     Dim hDll                      As Local Dword
     Dim lpFuncNameRef             As Local Dword Ptr
     Dim lpFuncAddr                As Local Dword Ptr
     Dim lpTypeOffset              As Word Ptr
     Dim TpOffset                  As Word
     Dim lpLink                    As Local Dword Ptr
     Dim fOldProtect               As Local Dword
     Dim i                         As Local Dword
     Dim j                         As Local Dword
     Dim k                         As Local Dword
     Dim Protection()              As Local Byte
     Dim Addr1                     As Local Dword
     Dim Addr2                     As Local Dword
     Dim Pg                        As Local Dword
     Dim Pg1                       As Local Dword
     Dim Pg2                       As Local Dword

     lpImageDosHeader = lpRawDll
     If RawDllSize < SizeOf(IMAGE_DOS_HEADER) Then Function = 1: Exit Function
     If @lpImageDosHeader.e_magic <> %IMAGE_DOS_SIGNATURE Then Function = 1: Exit Function ' invalid DOS signature
     If RawDllSize < @lpImageDosHeader.e_lfanew + SizeOf(IMAGE_NT_HEADERS) Then Function = 1: Exit Function
     lpImageNtHeaders = lpImageDosHeader + @lpImageDosHeader.e_lfanew
     If @lpImageNtHeaders.Signature <> %IMAGE_NT_SIGNATURE Then Function = 1: Exit Function ' invalid NT signature
     If @lpImageNtHeaders.FileHeader.SizeOfOptionalHeader <> SizeOf(@lpImageNtHeaders.OptionalHeader) Or _
        @lpImageNtHeaders.OptionalHeader.Magic <> %IMAGE_NT_OPTIONAL_HDR32_MAGIC Then Function = 1: Exit Function
     If @lpImageNtHeaders.FileHeader.NumberOfSections < 1 Then Function = 1: Exit Function

     For i = 0 To %IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1
        If @lpImageNtHeaders.OptionalHeader.DataDirectory(i).VirtualAddress <> 0 Then
           Select Case As Long i
              Case %IMAGE_DIRECTORY_ENTRY_EXPORT     ' Export Directory
              Case %IMAGE_DIRECTORY_ENTRY_IMPORT     ' Import Directory
              Case %IMAGE_DIRECTORY_ENTRY_RESOURCE   ' Resource Directory
              Case %IMAGE_DIRECTORY_ENTRY_BASERELOC  ' Base Relocation Table
              Case %IMAGE_DIRECTORY_ENTRY_IAT        ' Import Address Table
              Case Else ' Strange for PB
                 Function = 2: Exit Function
          End Select
        End If
     Next

     lpImageSectionHeader = lpImageNtHeaders + SizeOf(IMAGE_NT_HEADERS)
     k = lpImageSectionHeader - lpImageDosHeader + SizeOf(IMAGE_SECTION_HEADER) * @lpImageNtHeaders.FileHeader.NumberOfSections
     j = k
     For i = 0 To @lpImageNtHeaders.FileHeader.NumberOfSections - 1
        j = Max(j, @lpImageSectionHeader[i].VirtualAddress + @lpImageSectionHeader[i].SizeOfRawData)
     Next

     GetSystemInfo sSysInfo
     ImagePages = j \ sSysInfo.dwPageSize: If (j Mod sSysInfo.dwPageSize) Then Incr ImagePages
     lpImageDll = VirtualAlloc(ByVal 0, CDwd(ImagePages * sSysInfo.dwPageSize), %MEM_COMMIT, %PAGE_EXECUTE_READWRITE)
     If lpImageDll = 0 Then Function = 5: Exit Function

     MoveMemory ByVal lpImageDll, ByVal lpRawDll, k
     For i = 0 To @lpImageNtHeaders.FileHeader.NumberOfSections - 1
        MoveMemory ByVal CDwd(lpImageDll + @lpImageSectionHeader[i].VirtualAddress), _
                   ByVal CDwd(lpRawDll + @lpImageSectionHeader[i].PointerToRawData), @lpImageSectionHeader[i].SizeOfRawData
     Next

     ' Switch to new image
     lpImageDosHeader = lpImageDll
     lpImageNtHeaders = lpImageDosHeader + @lpImageDosHeader.e_lfanew
     lpImageSectionHeader = lpImageNtHeaders + SizeOf(IMAGE_NT_HEADERS)


     ' Import section
     
     '---Start Original code BY Semen
     '      lpImageImportDescriptor = @lpImageNtHeaders.OptionalHeader.DataDirectory(%IMAGE_DIRECTORY_ENTRY_IMPORT).VirtualAddress
     '      If lpImageImportDescriptor <> 0 Then
     '         lpImageImportDescriptor = lpImageImportDescriptor + lpImageDosHeader
     '         While @lpImageImportDescriptor.OriginalFirstThunk <> 0 ' Dlls
     '            lpDllName = @lpImageImportDescriptor.pName + lpImageDosHeader
     '            szDllName = @lpDllName
     '            hDll = GetModuleHandle(ByVal StrPtr(szDllName))
     '            If hDll = 0 Then hDll = LoadLibrary(ByVal StrPtr(szDllName))
     '            If hDll = 0 Then Function = 2: Exit Function ' Can't find
     '            lpFuncNameRef = @lpImageImportDescriptor.OriginalFirstThunk + lpImageDosHeader
     '            lpFuncAddr = @lpImageImportDescriptor.FirstThunk + lpImageDosHeader
     '            While @lpFuncNameRef <> 0
     '               lpImageImportByName = @lpFuncNameRef + lpImageDosHeader
     '               If (@lpFuncNameRef And %IMAGE_ORDINAL_FLAG) Then _
     '                  @lpFuncAddr = GetProcAddress(hDll, ByVal @lpFuncNameRef And &HFFFF???) Else _
     '                  @lpFuncAddr = GetProcAddress(hDll, @lpImageImportByName.ImpName)
     '               If @lpFuncAddr = 0 Then Function = 2: Exit Function
     '               Incr lpFuncAddr
     '               Incr lpFuncNameRef
     '            Wend
     '            Incr lpImageImportDescriptor
     '         Loop
     '      End If
     '---End Original code BY Semen

     '---Start Original code BY Lothar
     lpImageImportDescriptor = @lpImageNtHeaders.OptionalHeader.DataDirectory(%IMAGE_DIRECTORY_ENTRY_IMPORT).VirtualAddress
     If lpImageImportDescriptor <> 0 Then
        lpImageImportDescriptor = lpImageImportDescriptor + lpImageDosHeader
       
        'msgbox hex$(lpImageImportDescriptor - lpImageDosHeader)

        While @lpImageImportDescriptor.OriginalFirstThunk <> 0 Or @lpImageImportDescriptor.FirstThunk <> 0 ' Dlls
           lpDllName = @lpImageImportDescriptor.pName + lpImageDosHeader
           szDllName = @lpDllName
           hDll = GetModuleHandle(ByVal StrPtr(szDllName))

           If hDll = 0 Then hDll = LoadLibrary(ByVal StrPtr(szDllName))
           If hDll = 0 Then Function = 2: Exit Function ' Can't find

           lpFuncNameRef = @lpImageImportDescriptor.OriginalFirstThunk + lpImageDosHeader

           lpFuncAddr = @lpImageImportDescriptor.FirstThunk + lpImageDosHeader
           If lpFuncNameRef = lpImageDosheader Then lpFuncNameRef = lpFuncAddr
           
           While @lpFuncNameRef <> 0
              lpImageImportByName = @lpFuncNameRef + lpImageDosHeader

              If (@lpFuncNameRef And %IMAGE_ORDINAL_FLAG) Then _
                 @lpFuncAddr = GetProcAddress(hDll, ByVal @lpFuncNameRef And &HFFFF???) Else _
                 @lpFuncAddr = GetProcAddress(hDll, @lpImageImportByName.ImpName)

              If @lpFuncAddr = 0 Then Function = 2: Exit Function
              Incr lpFuncAddr
              Incr lpFuncNameRef
           Wend
           Incr lpImageImportDescriptor
        Loop
       
     End If
     '---End Original code BY Lothar

     lpImageBaseRelocTable = @lpImageNtHeaders.OptionalHeader.DataDirectory(%IMAGE_DIRECTORY_ENTRY_BASERELOC).VirtualAddress
     If lpImageBaseRelocTable <> 0 Then
        lpImageBaseRelocTable = lpImageBaseRelocTable + lpImageDosHeader
        While @lpImageBaseRelocTable.VirtualAddress <> 0
           lpTypeOffset = lpImageBaseRelocTable + SizeOf(IMAGE_BASE_RELOCATION)
           While lpTypeOffset < lpImageBaseRelocTable + @lpImageBaseRelocTable.SizeOfBlock
              TpOffset = @lpTypeOffset And &HF000??
              If TpOffset = &H3000 Then
                 lpLink = lpImageDosHeader + @lpImageBaseRelocTable.VirtualAddress + (@lpTypeOffset And &HFFF??)
                 @lpLink = @lpLink - @lpImageNtHeaders.OptionalHeader.ImageBase + lpImageDosHeader
              ElseIf TpOffSet = 0 Then
              Else
                 Function = 3: Exit Function ' Uknown type
              End If
              Incr lpTypeOffset
           Wend
           lpImageBaseRelocTable = lpImageBaseRelocTable + @lpImageBaseRelocTable.SizeOfBlock
        Wend
     End If

     ReDim Protection(ImagePages - 1)

     For i = 0 To @lpImageNtHeaders.FileHeader.NumberOfSections
        If i = @lpImageNtHeaders.FileHeader.NumberOfSections Then
           Addr1 = 0: Addr2 = k: j = &H60000000??? ' %PAGE_EXECUTE_READ
        Else
           Addr1 = @lpImageSectionHeader[i].VirtualAddress
           Addr2 = @lpImageSectionHeader[i].SizeOfRawData
           j = @lpImageSectionHeader[i].Characteristics
        End If
        Addr2 = Addr1 + Addr2 - 1
        Pg1 = Addr1 \ sSysInfo.dwPageSize
        Pg2 = Addr2 \ sSysInfo.dwPageSize
        For Pg = Pg1 To Pg2
           If (j And &H20000000???) Then Protection(Pg) = Protection(Pg) Or 1 ' Execute
           If (j And &H40000000???) Then Protection(Pg) = Protection(Pg) Or 2 ' Read
           If (j And &H80000000???) Then Protection(Pg) = Protection(Pg) Or 4 ' Write
        Next
     Next
     Addr1 = lpImageDosHeader
     For Pg = 0 To ImagePages - 1
        Select Case As Long Protection(Pg)
           Case 2: fOldProtect = %PAGE_READONLY
           Case 3: fOldProtect = %PAGE_EXECUTE_READ
           Case 6: fOldProtect = %PAGE_READWRITE
           Case Else: fOldProtect = %PAGE_EXECUTE_READWRITE ' Ignore strange combinations
        End Select
        If fOldProtect <> %PAGE_EXECUTE_READWRITE Then _
           If VirtualProtect (ByVal Addr1, sSysInfo.dwPageSize, fOldProtect, fOldProtect) = 0 Then Function = 4: Exit Function
        Addr1 = Addr1 + sSysInfo.dwPageSize
     Next

     i = @lpImageNtHeaders.OptionalHeader.AddressOfEntryPoint + lpImageDosHeader
     Call Dword i Using EntryPoint (lpImageDosHeader, %DLL_PROCESS_ATTACH, 0)
  End Function

''-----------------------------------------
''  Yeah, I'm the King Of The PE Format! I found the bug in LoadPBDLLFromMemory.
''  Actually it Is a linker bug. I Read there:
''  http://win32assembly.online.fr/pe-tut6.htmlQuote:
''  If OriginalFirstThunk Is zero, use the value In FirstThunk instead.
''  Some linkers generate PE files With 0 In OriginalFirstThunk. This Is considered a bug.
''  Just To be On the safe side, we Check the value In OriginalFirstThunk first.
''  
''  So I modified the import section processing Code As follows:
'
'      lpImageImportDescriptor = @lpImageNtHeaders.OptionalHeader.DataDirectory(%IMAGE_DIRECTORY_ENTRY_IMPORT).VirtualAddress
'      If lpImageImportDescriptor <> 0 Then
'         lpImageImportDescriptor = lpImageImportDescriptor + lpImageDosHeader
'        
'         'msgbox hex$(lpImageImportDescriptor - lpImageDosHeader)
'
'         While @lpImageImportDescriptor.OriginalFirstThunk <> 0 Or @lpImageImportDescriptor.FirstThunk <> 0 ' Dlls
'            lpDllName = @lpImageImportDescriptor.pName + lpImageDosHeader
'            szDllName = @lpDllName
'            hDll = GetModuleHandle(ByVal StrPtr(szDllName))
'
'            If hDll = 0 Then hDll = LoadLibrary(ByVal StrPtr(szDllName))
'            If hDll = 0 Then Function = 2: Exit Function ' Can't find
'
'            lpFuncNameRef = @lpImageImportDescriptor.OriginalFirstThunk + lpImageDosHeader
'
'            lpFuncAddr = @lpImageImportDescriptor.FirstThunk + lpImageDosHeader
'            If lpFuncNameRef = lpImageDosheader Then lpFuncNameRef = lpFuncAddr
'            
'            While @lpFuncNameRef <> 0
'               lpImageImportByName = @lpFuncNameRef + lpImageDosHeader
'
'               If (@lpFuncNameRef And %IMAGE_ORDINAL_FLAG) Then _
'                  @lpFuncAddr = GetProcAddress(hDll, ByVal @lpFuncNameRef And &HFFFF???) Else _
'                  @lpFuncAddr = GetProcAddress(hDll, @lpImageImportByName.ImpName)
'
'               If @lpFuncAddr = 0 Then Function = 2: Exit Function
'               Incr lpFuncAddr
'               Incr lpFuncNameRef
'            Wend
'            Incr lpImageImportDescriptor
'         Loop
'        
'      End If
''-----------------------------------------










  Function UnloadPbDllFromMemory (ByVal lpImageDosHeader As IMAGE_DOS_HEADER Ptr) As Dword
     Dim lpImageNtHeaders          As Local IMAGE_NT_HEADERS Ptr
     Dim i                         As Local Dword

     lpImageNtHeaders = lpImageDosHeader + @lpImageDosHeader.e_lfanew
     i = @lpImageNtHeaders.OptionalHeader.AddressOfEntryPoint + lpImageDosHeader
     Call Dword i Using EntryPoint (lpImageDosHeader, %DLL_PROCESS_DETACH, 0)
     Function = VirtualFree (ByVal lpImageDosHeader, 0, %MEM_RELEASE)
  End Function
  '-----------------------------------------------


Than in your Main source add something like this in order to load resource name (rename the function as you prefer AND CHANGE the name of the executable to load resource data DLL from)

 '------------------------------------------------------------------------------
 Function thinAir_Editor_LoadLib_FromResource(ByVal RCNAME As String) As Long
 '------------------------------------------------------------------------------

   Local sPath     As String
   Local hLib      As Long
   Local hInst???
   Local Res???
   Local Res2???
   Local Res3???
   Local sBuffer   As String    
   Local lRetCode  As Long
           
   sPath = "thinAir.exe"                  '<<<<<<<<<<<<<<<<<< Change to your EXE name
   hLib = LoadLibrary( ByCopy sPath )

   If hLib <> %Null Then
     hInst??? = GetModuleHandle("")                                  '' ID this
     Res??? = FindResource(hLib, ByCopy RCNAME, ByVal %RT_RCDATA)       '' find target
     Res2??? = LoadResource(hLib, Res???)                        '' load target
     Res3??? = LockResource(Res2???)                                 '' lock target
     sBuffer = Peek$(Res3???, SizeofResource(hLib, Res???))   '' extract target, any name

     lRetCode = LoadPbDllFromMemory (StrPtr(sBuffer), Len(sBuffer), hLib)

     Function = hLib
     
   End If
 End Function


In your main function load your DLL from memory and get all needed function pointers remapped:

   '--------------------------------------
     '---Load ZBFF control from resource
     ghLib_zBFF        = thinAir_Editor_LoadLib_FromResource("RCZBFF")   '---<<< Same name given in RC file
     '---Get ProcAddresses of needed exported functions
     ghLib_zBFF_Proc_RegisterBFFClass  = GetProcAddressDirectly(ghLib_zBFF, "RegisterBFFClass")
     ghLib_zBFF_Proc_Bff_zBrowser      = GetProcAddressDirectly(ghLib_zBFF, "zBrowser")
     ghLib_zBFF_Proc_Bff_SetProperty   = GetProcAddressDirectly(ghLib_zBFF, "Bff_SetProperty")
     ghLib_zBFF_Proc_Bff_GetPath       = GetProcAddressDirectly(ghLib_zBFF, "Bff_GetPath")
     ghLib_zBFF_Proc_Bff_JumpToPath    = GetProcAddressDirectly(ghLib_zBFF, "Bff_JumpToPath")


Now you are ready to call your functions using CALL DWORD and correct function declares. Example:
     '---Register the control class
     Call Dword ghLib_zBFF_Proc_RegisterBFFClass Using BFF_RegisterBFFClass() To ghLib_zBFF_lResult



I've used this method from WIN9X to Windows 7 and under many different AV software.
Hope this can help.

Ciao
Eros
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Eros Olmi

thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Eros Olmi

Back to my original question about having shell file icons, I've found the solution.

Get from the shell a system image icon list in this way
'---Shell icons
Local udtSHFileInfo   As SHFILEINFO
Local hLVImageList    As Long
'---Retrieve the index of a system image list icon
hLVImageList = SHGetFileInfo("C:\", 0, udtSHFileInfo, SizeOf(udtSHFileInfo), %SHGFI_USEFILEATTRIBUTES Or %SHGFI_SMALLICON Or %SHGFI_SYSICONINDEX)


Than assign it to your list view
'---Assign the new image list to the listview
ListView_SetImageList g_tDockInfo.hFileList, hLVImageList, %LVSIL_SMALL


When adding a new item to your listview use the following function to get the icon index passing the full path name:
SFF_GetIconIndex(sPath & FileName)
FUNCTION SFF_GetIconIndex(BYVAL strFilePath AS STRING) AS DWORD
' Purpose:      lookup icon handle for specified file
' Parameters:   strFilePath - path and filename of specific file or folder
' Returns:      handle to icon image in system image list
    LOCAL udtSHFileInfo AS SHFILEINFO

    SHGetFileInfo BYVAL STRPTR(strFilePath), 0, udtSHFileInfo, SIZEOF(udtSHFileInfo), %SHGFI_SMALLICON OR %SHGFI_SYSICONINDEX
    FUNCTION = udtSHFileInfo.iIcon
END FUNCTION


Full code example can be found here: http://www.powerbasic.com/support/pbforums/showthread.php?t=23970&highlight=SFF_GetIconIndex
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Patrice Terrier

#14
Eros,

Because the link was broken, i have used Poffs, to get the missing parts of the code.
Also there are several problems when mixing STR and ASCIIZ, i have fixed them quickly using () around string to pass them by copy.

See the attached "working" code.

Note: I didn't had time to translate this to plain SDK.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com