Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

TROUVER LE NOM LONG À PARTIR DU NOM MS-DOS 8.3


Information sur la source

Catégorie :Fichier / Disque Classé sous : nom, msdos, dos Niveau : Expert Date de création : 05/08/2001 Vu : 2 025

Note :
5,5 / 10 - par 4 personnes
5,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

Description

Copiez le code dans un .BAS et exécuter la fonction comme ceci:
nom_long=trouve_le_nom_long("C:\PROGRA~1\YES.EXE")

Vous avez besoin d'un dirlistbox appelé dir1,d'une listbox appelée liste et d'un filelistbox appelé file1
Voilà, en espèrant que ce code va en aider plus d'un...
 

Source

  • Public Function trouve_le_nom_long(file As String) As String
  • Dir1.Path = "\"
  • chemin = "\"
  • position = 4
  • Do
  • a = InStr(position + 1, file, "\")
  • If a = 0 Then GoTo fin
  • dossier = Mid(file, position, a - position)
  • If InStr(1, dossier, "~") <> 0 Then
  • If chemin <> "\" Then
  • If Right(Dir1.Path, 1) = "\" Then
  • nom = Dir1.Path
  • Else: nom = Dir1.Path & "\"
  • End If
  • position = Len(nom) + 1
  • End If
  • For i = 0 To Dir1.ListCount - 1
  • If Left(dossier, InStr(1, dossier, "~") - 1) = UCase(Mid(Dir1.List(i), position, Len(Left(dossier, InStr(1, dossier, "~") - 1)))) And Len(Mid(Dir1.List(i), position)) > 8 Then
  • incr = Len(Dir1.List(i)) + 1
  • Do
  • incr = incr - 1
  • Loop Until Mid(Dir1.List(i), incr, 1) = "\"
  • zaza = Right(Dir1.List(i), Len(Dir1.List(i)) - incr)
  • Liste.AddItem (zaza)
  • End If
  • Next
  • chemin = chemin & Liste.List(Right(dossier, 1) - 1) & "\"
  • Liste.Clear
  • Else
  • For i = 0 To Dir1.ListCount - 1
  • If UCase(Right(Dir1.List(i), Len(dossier))) = dossier Then dossier = Right(Dir1.List(i), Len(dossier))
  • Next
  • chemin = chemin & dossier & "\"
  • End If
  • Dir1.Path = chemin
  • position = a + 1
  • Loop
  • fin:
  • trouve_le_nom_long = Dir1.Path
  • namen = trouve_le_nom_du_fichier(file, Dir1.Path)
  • If Right(trouve_le_nom_long, 1) = "\" Then
  • trouve_le_nom_long = trouve_le_nom_long & namen
  • Else: trouve_le_nom_long = trouve_le_nom_long & "\" & namen
  • End If
  • End Function
  • Public Function trouve_le_nom_du_fichier(abc As String, chemin_initial As String) As String
  • Liste.Clear
  • File1.Path = chemin_initial
  • incr = Len(abc) + 1
  • Do
  • incr = incr - 1
  • Loop Until Mid(abc, incr, 1) = "\"
  • nom = Mid(abc, incr + 1)
  • a = InStr(1, nom, "~")
  • If a = 0 Then
  • For i = 0 To File1.ListCount - 1
  • If UCase(File1.List(i)) = nom Then
  • trouve_le_nom_du_fichier = File1.List(i)
  • End If
  • Next
  • GoTo fin
  • Else
  • For i = 0 To File1.ListCount - 1
  • If Left(nom, 6) = UCase(Mid(File1.List(i), 1, Len(Left(nom, 6)))) Then
  • Liste.AddItem (File1.List(i))
  • End If
  • Next
  • trouve_le_nom_du_fichier = Liste.List(Val(Mid(nom, InStr(1, nom, "~") + 1)) - 1)
  • End If
  • fin:
  • End Function
Public Function trouve_le_nom_long(file As String) As String

Dir1.Path = "\"
chemin = "\"
position = 4
Do
a = InStr(position + 1, file, "\")
If a = 0 Then GoTo fin

dossier = Mid(file, position, a - position)


If InStr(1, dossier, "~") <> 0 Then

If chemin <> "\" Then

    If Right(Dir1.Path, 1) = "\" Then
    nom = Dir1.Path
    Else: nom = Dir1.Path & "\"
    
End If

position = Len(nom) + 1

End If




For i = 0 To Dir1.ListCount - 1
If Left(dossier, InStr(1, dossier, "~") - 1) = UCase(Mid(Dir1.List(i), position, Len(Left(dossier, InStr(1, dossier, "~") - 1)))) And Len(Mid(Dir1.List(i), position)) > 8 Then


incr = Len(Dir1.List(i)) + 1
Do
incr = incr - 1
Loop Until Mid(Dir1.List(i), incr, 1) = "\"

zaza = Right(Dir1.List(i), Len(Dir1.List(i)) - incr)



Liste.AddItem (zaza)
End If

Next

chemin = chemin & Liste.List(Right(dossier, 1) - 1) & "\"
Liste.Clear


Else


For i = 0 To Dir1.ListCount - 1
If UCase(Right(Dir1.List(i), Len(dossier))) = dossier Then dossier = Right(Dir1.List(i), Len(dossier))
Next

chemin = chemin & dossier & "\"

End If

Dir1.Path = chemin

position = a + 1



Loop


fin:
trouve_le_nom_long = Dir1.Path
namen = trouve_le_nom_du_fichier(file, Dir1.Path)
If Right(trouve_le_nom_long, 1) = "\" Then
trouve_le_nom_long = trouve_le_nom_long & namen
Else: trouve_le_nom_long = trouve_le_nom_long & "\" & namen
End If




End Function






Public Function trouve_le_nom_du_fichier(abc As String, chemin_initial As String) As String

Liste.Clear


File1.Path = chemin_initial

incr = Len(abc) + 1
Do
incr = incr - 1
Loop Until Mid(abc, incr, 1) = "\"

nom = Mid(abc, incr + 1)


a = InStr(1, nom, "~")
If a = 0 Then

For i = 0 To File1.ListCount - 1
If UCase(File1.List(i)) = nom Then
trouve_le_nom_du_fichier = File1.List(i)
End If
Next

GoTo fin

Else



For i = 0 To File1.ListCount - 1
If Left(nom, 6) = UCase(Mid(File1.List(i), 1, Len(Left(nom, 6)))) Then

Liste.AddItem (File1.List(i))
End If

Next

trouve_le_nom_du_fichier = Liste.List(Val(Mid(nom, InStr(1, nom, "~") + 1)) - 1)



End If


fin:

End Function
 

Commentaires et avis

signaler à un administrateur
Commentaire de florantanplan le 26/04/2004 16:13:38

Déclarer les variables, tu connais!!!

Ajouter un commentaire

Discussions en rapport avec ce code source dans le forum

Détecter fermeture fenêtre MSDos [ par Asghaard ] Bonjour,Après avoir longuement cherché, j'en arrive à vous poser la question :Comment détecter la fin du procédure en MSDOS </stro Net send de dos en VB [ par benji547 ] J'aimerai s'avoir si il existe une comande similaire a net send sous msdos ou le moyen d'utiliser les commandes msdos. Merci Utilisation de Netsh [ par XavierH ] Salut,Je cherche a utiliser la fonction "netsh" dans une appli.Sous Dos la ligne "netsh -c interface dump &gt; C:\config-bureau.cfg" marche impec et s Incérer les commandes Dos dans VB [ par Hach_net ] Salut Je veux appeler des commandes Dos dans mon projet VB Comment je peux faireMerci <IMG src="/i Programme vb6 executable en DOS [ par khadd007 ] Bonjour :)Je voudrais developper une application en vb6 ex&#233;cutable en DOS. Je m'explique, mon but &#233;tant de faire un menu ghost qui permettra saisie dans le DOS pour VBscript [VBS] [ par Amandine62 ] Salut! Voila, J'ai fait mon script il fonctionne correctement mais en fait il ne faut plus du tout q Variable VB dans commande DOS [ par drouault ] Bonjour à tous; Voici le souci : j'éxécute à partir de VB6 une commande dos qui me permet de lancer une requête qui exporte des données au format exce Variable VB dans commande DOS [ par drouault ] Bonjour à tous; Voici le souci : j'éxécute à partir de VB6 une commande dos qui me permet de lancer une requête qui exporte des données au format exce Tempo C sous DOS en miliseconde? [ par pcman5 ] Voila, j'utilise le compilateur QuickC sous DOS et je cherche a faire une temporisation en miliseconde. La fonction Sleep n'existant pas. (En tous cas Recup Terminal DOS [ par eldim ] Bonjour,Est-ce quelqu'un connais un moyen de r&#233;cup&#233;rer le contenu d'une fenetre DOS dans un richtextbox ou autre En VB6 y avait une police T


Nos sponsors

Sondage...

CalendriCode

Juillet 2009
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
2728293031  

Consulter la suite du CalendriCode

Téléchargements

Comparez les prix Nouvelle version

Photothèque Nouveau !



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,515 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.