What is the best way to find out where notepad.exe and mspaint.exe are that will work across various versions of Windows?
Should I get the Windows directory via SHGetFol
In short I find that the best approach
is to check the
Windows\System32
directory
and the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
registry keys.
More generally I find that the best approach
is to mimic ShellExecuteEx
.
Taken from:
Application Registration (Windows)
https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121(v=vs.85).aspx
The file is sought in the following locations:
•The current working directory.
•The Windows directory only (no subdirectories are searched).
•The Windows\System32 directory.
•Directories listed in the PATH environment variable.
•Recommended: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
A further possibly is to check Start Menu\Programs\Accessories
,
by using SHGetFolderPath
with CSIDL_STARTMENU := 11
and CSIDL_COMMON_STARTMENU := 22
, and retrieve the targets
from the lnk files.