Use ShellExecute to open INI files in the launcher

This commit is contained in:
Eddoursul 2026-09-15 12:39:52 +02:00
parent 74dbcd14c1
commit 505c79c348

View File

@ -258,38 +258,9 @@ Func UpdateModIniButtonState()
EndFunc EndFunc
Func RunWithAssociation($filePath) Func RunWithAssociation($filePath)
; Get file extension ; The shell resolves the association and expands REG_EXPAND_SZ paths itself
Local $ext = StringRegExpReplace($filePath, ".*(\.[^.]+)$", "$1") ShellExecute($filePath)
If $ext = $filePath Then Return False If @error Then Run('notepad.exe "' & $filePath & '"')
; Get file type from registry
Local $fileType = RegRead("HKEY_CLASSES_ROOT\" & $ext, "")
If @error Or $fileType = "" Then
; Fallback to notepad if no association found
Run('notepad.exe "' & $filePath & '"')
Return True
EndIf
; Get command for opening this file type
Local $command = RegRead("HKEY_CLASSES_ROOT\" & $fileType & "\shell\open\command", "")
If @error Or $command = "" Then
; Fallback to notepad if no command found
Run('notepad.exe "' & $filePath & '"')
Return True
EndIf
; Replace %1 or %L with the file path, handle quoted and unquoted variants
If StringInStr($command, "%1") Or StringInStr($command, "%L") Then
$command = StringReplace($command, '"%1"', '"' & $filePath & '"')
$command = StringReplace($command, "%1", '"' & $filePath & '"')
$command = StringReplace($command, '"%L"', '"' & $filePath & '"')
$command = StringReplace($command, "%L", '"' & $filePath & '"')
Else
; Append file path if no placeholder
$command = $command & ' "' & $filePath & '"'
EndIf
Run($command)
Return True Return True
EndFunc EndFunc