[我正在尝试将两个文件扩展名与我的程序(.exe文件)相关联,可以说它们分别是ext1
和ext2
。
我想以一种方式将ext1
文件与我的程序相关联,如果它是外壳执行的,则此命令行(或命令)应运行\执行:
my_program.exe shell_execute ext1 "<full path of the file>"
类似地ext2
:
my_program.exe shell_execute ext2 "<full path of the file>"
如何将文件扩展名与程序关联?
这是一个简单的文件关联解决方案,
; e.g.
;_FiletypeAssociation('.test', 'test', 'notepad "%1"', 'test description')
;_FiletypeAssociation('.pdf', 'FoxitReader.Document', '"%ProgramFiles%\FoxitReader.exe" "%1"')
Func _FiletypeAssociation($extension, $type, $program, $description = '')
Local $sHKCR = @OSArch = 'x64' ? 'HKCR64' : 'HKCR'
$exitcode = RunWait(@ComSpec & ' /c ftype ' & $type & '=' & $program & _
' && assoc ' & $extension & '=' & $type, '', @SW_HIDE)
If $description And Not $exitcode Then
Return RegWrite($sHKCR & '\' & $type, '', 'Reg_sz', $description)
EndIf
Return Not $exitcode
EndFunc