Visualizzazione dei risultati da 1 a 9 su 9

Hybrid View

  1. #1
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,477
    Quote Originariamente inviata da giorgiogio48 Visualizza il messaggio
    Grazie per l'intervento. No alka, l'eccezione è gestita. Ma il problema permane
    L'eccezione è gestita ma il problema permane, quindi è gestita male.

    Non pubblichi altri dettagli né hai risposto ai dubbi esposti, quindi evidentemente non ti serve una mano.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  2. #2
    Ecco. La funzione che interessa è questa. Non interviene più il debugger perchè, come ho detto, ho eliminato a mano le cartelle a cui era negato l'accesso
    codice:
     Public Sub ExtractAssociatedIconEx1()
            Try
                Dim folderName As String = Nothing
                If (Environment.GetCommandLineArgs.Length > 1) Then
                    folderName = Environment.GetCommandLineArgs(1)
    
                End If
    
    
                ' Get the c:\ directory.
    
    
                If RadioButton1.Checked = True Then
    
                    lstResults.Items.Clear()
                    lstResults.LargeImageList = ImageList1
                    lstResults.SmallImageList = ImageList1
                    lstResults.View = View.List
    
                    Dim dirInfo As DirectoryInfo
                    Dim fileInfo As FileInfo
                    Dim exeIcon As System.Drawing.Icon
                    Dim sh As New NativeMethods.SHFILEINFO
    
                    dirInfo = New DirectoryInfo("C:\Users\giorg\Documents\")
    
                    For Each fileInfo In dirInfo.GetFiles("*" & TextBox1.Text & "*", SearchOption.AllDirectories)
                        ImageList1.ColorDepth = ColorDepth.Depth32Bit
                        sh = NativeMethods.GetInfoFromShell(fileInfo.FullName)
                        If (Not String.IsNullOrEmpty(fileInfo.Extension)) Then
    
                            exeIcon = CType(System.Drawing.Icon.FromHandle(sh.hIcon).Clone, Icon)
    
    
                            ImageList1.ColorDepth = ColorDepth.Depth32Bit
                            sh = NativeMethods.GetInfoFromShell(fileInfo.FullName)
                            If (Not String.IsNullOrEmpty(fileInfo.Extension)) Then
    
                                exeIcon = CType(System.Drawing.Icon.FromHandle(sh.hIcon).Clone, Icon)
    
                                If (ImageList1.Images.ContainsKey(fileInfo.Name)) Then
                                    lstResults.Items.Add(fileInfo.FullName, fileInfo.FullName)
                                ElseIf (Not exeIcon Is Nothing) Then
                                    ImageList1.Images.Add(fileInfo.FullName, exeIcon)
                                    lstResults.Items.Add(fileInfo.FullName, fileInfo.FullName)
                                Else
                                    lstResults.Items.Add(fileInfo.FullName)
                                End If
    
                            End If
                        End If
                    Next
    
                Else
                    lstResults.Items.Clear()
                    lstResults.LargeImageList = ImageList1
                    lstResults.SmallImageList = ImageList1
                    lstResults.View = View.List
    
                    Dim dirInfo As DirectoryInfo
                    Dim fileInfo As FileInfo
                    Dim exeIcon As System.Drawing.Icon
                    Dim sh As New NativeMethods.SHFILEINFO
    
                    dirInfo = New DirectoryInfo("C:\Users\giorg\Documents\")
    
                    For Each fileInfo In dirInfo.GetFiles("*" & TextBox1.Text & "*", SearchOption.AllDirectories)
                        ImageList1.ColorDepth = ColorDepth.Depth32Bit
                        sh = NativeMethods.GetInfoFromShell(fileInfo.FullName)
                        If (Not String.IsNullOrEmpty(fileInfo.Extension)) Then
    
                            exeIcon = CType(System.Drawing.Icon.FromHandle(sh.hIcon).Clone, Icon)
    
    
                            ImageList1.ColorDepth = ColorDepth.Depth32Bit
                            sh = NativeMethods.GetInfoFromShell(fileInfo.FullName)
                            If (Not String.IsNullOrEmpty(fileInfo.Extension)) Then
    
                                exeIcon = CType(System.Drawing.Icon.FromHandle(sh.hIcon).Clone, Icon)
    
                                If (ImageList1.Images.ContainsKey(fileInfo.Name)) Then
                                    lstResults.Items.Add(fileInfo.FullName, fileInfo.FullName)
                                ElseIf (Not exeIcon Is Nothing) Then
                                    ImageList1.Images.Add(fileInfo.FullName, exeIcon)
                                    lstResults.Items.Add(fileInfo.FullName, fileInfo.FullName)
                                Else
                                    lstResults.Items.Add(fileInfo.FullName)
                                End If
    
                            End If
                        End If
                    Next
    
                End If
    
    
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
    
    
    
        End Sub
    Ultima modifica di alka; 01-06-2022 a 09:06 Motivo: Usato il tag corretto per formattare il codice
    Giorgio
    L'esperienza è il tipo di insegnante più difficile. Prima ti fa l'esame, e poi ti spiega la lezione. (Oscar Wilde)

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.