With current Windows versions,
#1 First you need look up HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\[EXT]\UserChoice\ProgId if it exists. If not, goto #5.
#2 The ProgId is a file-class, e.g. Python.File (=> goto #6) or similarly an application-id, e.g. Applications\SciTE.exe (=> goto #3)
#3 Locate the application id Applications\SciTE.exe like HKEY_CLASSES_ROOT\Applications\SciTE.exe\shell\open\command. The default value is the command to run.
#4 Done.
#5 Lookup Computer\HKEY_CLASSES_ROOT\[EXT] 's default value for a file-class, e.g. Python.File
#6 Lookup the file-class Python.File like HKEY_CLASSES_ROOT\Python.File\shell. The default value is a default command, e.g. edit (defaults to open if not existing).
#7 Look up its edit command like HKEY_CLASSES_ROOT\Python.File\shell\edit\command. The default value is the command to run. Note: The other available commands for a file-class are shown in Explorer, when right-clicking on a file.
Note: HKEY_CLASSES_ROOT joins the Software\Classes of HKEY_CURRENT_USER (higher priority) and HKEY_LOCAL_MACHINE