Code : Tout sélectionner
Procedure AssociateFileEx(ext$,ext_description$,programm$,Icon$,prgkey$,cmd_description$,cmd_key$)
cmd$=Chr(34)+programm$+Chr(34)+" "+Chr(34)+"%1"+Chr(34)
If GetVersion_() & $FF0000 ; Windows NT/XP
SetKey(#HKEY_CLASSES_ROOT, "Applications\"+prgkey$+"\shell\"+cmd_description$+"\command","",#REG_SZ ,@cmd$,Len(cmd$)+1)
If ext_description$
Key$=ext$+"_auto_file"
SetKey(#HKEY_CLASSES_ROOT ,"."+ext$ ,"",#REG_SZ,@Key$,Len(Key$)+1)
SetKey(#HKEY_CLASSES_ROOT ,Key$ ,"",#REG_SZ,@ext_description$,Len(ext_description$)+1)
If Icon$
SetKey(#HKEY_CLASSES_ROOT,Key$+"\DefaultIcon","",#REG_SZ,@Icon$,Len(Icon$)+1)
EndIf
EndIf
SetKey(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\."+ext$,"Application",#REG_SZ,@prgkey$ ,Len(prgkey$)+1)
Else ;Windows 9x
SetKey(#HKEY_LOCAL_MACHINE,"Software\Classes\."+ext$ ,"",#REG_SZ,@prgkey$ ,Len(prgkey$)+1)
If ext_description$
SetKey(#HKEY_LOCAL_MACHINE,"Software\Classes\"+prgkey$ ,"",#REG_SZ,@ext_description$,Len(ext_description$)+1)
EndIf
If Icon$
SetKey(#HKEY_LOCAL_MACHINE,"Software\Classes\"+prgkey$+"\DefaultIcon" ,"",#REG_SZ,@Icon$ ,Len(Icon$)+1)
EndIf
If cmd_description$<>cmd_key$
SetKey(#HKEY_LOCAL_MACHINE,"Software\Classes\"+prgkey$+"\shell\"+cmd_key$,"",#REG_SZ,@cmd_description$,Len(cmd_description$)+1)
EndIf
SetKey(#HKEY_LOCAL_MACHINE,"Software\Classes\"+prgkey$+"\shell\"+cmd_key$+"\command","",#REG_SZ,@cmd$ ,Len(cmd$)+1)
EndIf
EndProcedure
Procedure AssociateFile(ext$,ext_description$,programm$,Icon$)
AssociateFileEx(ext$,ext_description$,programm$,Icon$,GetFilePart(programm$),"open","open")
EndProcedure
Si je me fie à la ligne 3 du code, c'est compatible uniquement XP et NT.