begin process at 2012 02 13 11:39:24
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > TROUVER LE PROGRAMME ASSOCIÉ À UN TYPE FICHIER

TROUVER LE PROGRAMME ASSOCIÉ À UN TYPE FICHIER


 Information sur la source

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

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :API Niveau :Débutant Date de création :29/01/2002 Date de mise à jour :29/01/2002 15:09:34 Vu :3 385

Auteur : dracer

Ecrire un message privé
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Ce programme permer de trouver à quel programme est associé un type de fichier.
Par exemple .pdf est associé à Acrobat reader si celui-ci est installé, etc...

Source

  • #If Win32 Then
  • Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
  • #Else
  • Private Declare Function FindExecutable Lib "shell.dll" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Integer
  • #End If
  • '***************FONCTION DE RECHERCHE
  • Private Function Rechexe(Monfichier As String) As String
  • Dim ChaineRet As String
  • Dim ChaineExe As String
  • 'Dcl en variant Int ou Long
  • Dim ret As Variant
  • ChaineRet = Space(100)
  • 'Recherche de l'exe en fonction du fichier associé
  • ret = FindExecutable(Monfichier, CurDir(), ChaineRet)
  • If ret <= 32 Then
  • ChaineExe = ""
  • Else
  • ChaineExe = Mid$(ChaineRet, 1, InStr(1, ChaineRet, Chr(0), 1) - 1)
  • End If
  • Form1.Print ChaineExe
  • Rechexe = ChaineExe
  • End Function
  • '***********************************
  • '***************CHERCHER ASSOCIATION
  • 'Essai de la fonction et lancement
  • Sub CmdOpen_Click()
  • Dim ret As Variant
  • Dim nomexe As String, nomfich As String
  • nomfich = "c:\1.pdf" 'Lien vers le fichier
  • nomexe = Rechexe(nomfich)
  • If nomexe <> "" Then
  • MsgBox "association trouvée"
  • Else
  • MsgBox "Pas d'association définie"
  • End If
  • End Sub
  • '***********************************
#If Win32 Then
    Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
#Else
    Private Declare Function FindExecutable Lib "shell.dll" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Integer
#End If

'***************FONCTION DE RECHERCHE
Private Function Rechexe(Monfichier As String) As String
    Dim ChaineRet As String
    Dim ChaineExe As String
    'Dcl en variant Int ou Long
    Dim ret As Variant

    ChaineRet = Space(100)
    'Recherche de l'exe en fonction du fichier associé
    ret = FindExecutable(Monfichier, CurDir(), ChaineRet)
    If ret <= 32 Then
        ChaineExe = ""
    Else
        ChaineExe = Mid$(ChaineRet, 1, InStr(1, ChaineRet, Chr(0), 1) - 1)
    End If
    Form1.Print ChaineExe
    Rechexe = ChaineExe
End Function
'***********************************

'***************CHERCHER ASSOCIATION
'Essai de la fonction et lancement
Sub CmdOpen_Click()

Dim ret As Variant
Dim nomexe As String, nomfich As String

nomfich = "c:\1.pdf" 'Lien vers le fichier
nomexe = Rechexe(nomfich)
If nomexe <> "" Then
MsgBox "association trouvée"
Else
MsgBox "Pas d'association définie"
End If
End Sub
'***********************************
 

 Conclusion

Ce code a été trouvé sur le MSN du site de Microsoft (merci à eux).


 Sources du même auteur

EXTRAIRE LE NOM DU FICHIER D'UN CHEMIN EN 1 COMMANDE

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) .NET DEPENDENCY VIEWER : ARBRE DES DÉPENDANCES D'UN ASSEMBLY... par ShareVB
Source avec Zip Source .NET (Dotnet) UTILITAIRE SKYDRIVE par MasterShadows
Source avec Zip ROTATION RAPIDE D'IMAGE par trex70
Source avec Zip Source avec une capture ENUMERATION DES PORTS TCP ET IDENTIFCATION DU PROCESS (PID) ... par Renfield
Source avec Zip Source avec une capture MOUSE SPEED AND WEIGHT : RETOUR DE FORCE VIRTUEL ! par ScSami

Commentaires et avis

Commentaire de LuTo le 02/02/2002 02:58:46

Cool. Je savais meme pas qu'on pouvais mettre du code en dehors d'une procedure.

Commentaire de cuq le 07/01/2008 13:17:36 10/10

ca marche ... on en demande pas plus

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
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

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,780 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales