_RegSetFileExt('jpg', 'C:\MyProgram.exe %1', 'Открыть с MyProgram', 0, 'C:\MyProgram.exe,0', 'Описание')
Func _RegSetFileExt($sExt, $sCommand, $sVerb, $iDefault = 0, $sIcon = "", $sDescription = "")
Local $sExtRead = RegRead("HKCR\." & $sExt, "")
If @error Then
RegWrite("HKCR\." & $sExt, "", $g_REGTYPE_REG_SZ, $sExt & "file")
$sExtRead = $sExt & "file"
EndIf
Local $sCurrentDescription = RegRead("HKCR\" & $sExtRead, "")
If @error Then
If $sDescription <> "" Then RegWrite("HKCR\" & $sExtRead, "", $g_REGTYPE_REG_SZ, $sDescription)
Else
If $sDescription <> "" And $sCurrentDescription <> $sDescription Then
RegWrite("HKCR\" & $sExtRead, "", $g_REGTYPE_REG_SZ, $sDescription)
RegWrite("HKCR\" & $sExtRead, "olddesc", $g_REGTYPE_REG_SZ, $sCurrentDescription)
EndIf
If $sCurrentDescription = "" And $sDescription <> "" Then RegWrite("HKCR\" & $sExtRead, "", $g_REGTYPE_REG_SZ, $sDescription)
EndIf
Local $sCurrentVerb = RegRead("HKCR\" & $sExtRead & "\shell", "")
Local $iError = @error
If $iDefault = 1 Then
RegWrite("HKCR\" & $sExtRead & "\shell\Open\Command", "", $g_REGTYPE_REG_EXPAND_SZ, $sCommand)
If $iError Then
RegWrite("HKCR\" & $sExtRead & "\shell", "", $g_REGTYPE_REG_SZ, $sVerb)
Else
RegWrite("HKCR\" & $sExtRead & "\shell", "", $g_REGTYPE_REG_SZ, $sVerb)
RegWrite("HKCR\" & $sExtRead & "\shell", "oldverb", $g_REGTYPE_REG_SZ, $sCurrentVerb)
EndIf
EndIf
Local $sCurrentCommand = RegRead("HKCR\" & $sExtRead & "\shell\" & $sVerb & "\command", "")
If Not @error Then
RegRead("HKCR\" & $sExtRead & "\shell\" & $sVerb & "\command", "oldcmd")
If @error Then RegWrite("HKCR\" & $sExtRead & "\shell\" & $sVerb & "\command", "oldcmd", $g_REGTYPE_REG_SZ, $sCurrentCommand)
EndIf
RegWrite("HKCR\" & $sExtRead & "\shell\" & $sVerb & "\command", "", $g_REGTYPE_REG_SZ, $sCommand)
If $sIcon <> "" Then
Local $sCurrentIcon = RegRead("HKCR\" & $sExtRead & "\DefaultIcon", "")
If @error Then
RegWrite("HKCR\" & $sExtRead & "\DefaultIcon", "", $g_REGTYPE_REG_SZ, $sIcon)
Else
RegWrite("HKCR\" & $sExtRead & "\DefaultIcon", "", $g_REGTYPE_REG_SZ, $sIcon)
RegWrite("HKCR\" & $sExtRead & "\DefaultIcon", "oldicon", $g_REGTYPE_REG_SZ, $sCurrentIcon)
EndIf
EndIf
EndFunc