Private Sub Command1_Click() 'Code testé VB6 Dim RegBot As New cRegistry Dim lPos As Long With CommonDialog1 .CancelError = True .DialogTitle = "Lire type fichier" .Filter = "Tous (*.*)|*.*" .FilterIndex = 1 .Flags = cdlOFNPathMustExist Or cdlOFNFileMustExist Or cdlOFNHideReadOnly .InitDir = "c:\my documents" .ShowOpen 'Pomper l'extension lPos = InStrRev(.FileTitle, ".") If lPos = 0 Then Exit Sub 'Type étape 1 RegBot.ClassKey = HKEY_CLASSES_ROOT RegBot.SectionKey = Right$(.FileTitle, Len(.FileTitle) - lPos + 1) RegBot.ValueKey = "" RegBot.ValueType = REG_SZ 'Type étape 2 RegBot.ClassKey = HKEY_CLASSES_ROOT RegBot.SectionKey = RegBot.Value RegBot.ValueKey = "" RegBot.ValueType = REG_SZ Text1 = RegBot.Value End With End Sub
Private Sub Command1_Click() 'Code testé VB6 Dim RegBot As New cRegistry Dim lPos As Long With CommonDialog1 .CancelError = True .DialogTitle = "Lire type fichier" .Filter = "Tous (*.*)|*.*" .FilterIndex = 1 .Flags = cdlOFNPathMustExist Or cdlOFNFileMustExist Or cdlOFNHideReadOnly .InitDir = "c:\my documents" .ShowOpen 'Pomper l'extension lPos = InStrRev(.FileTitle, ".") If lPos = 0 Then Exit Sub 'Type étape 1 RegBot.ClassKey = HKEY_CLASSES_ROOT RegBot.SectionKey = Right$(.FileTitle, Len(.FileTitle) - lPos + 1) RegBot.ValueKey = "" RegBot.ValueType = REG_SZ 'Type étape 2 RegBot.ClassKey = HKEY_CLASSES_ROOT RegBot.SectionKey = RegBot.Value RegBot.ValueKey = "" RegBot.ValueType = REG_SZ Text1 = RegBot.Value End With End Sub