Locate Path To Specific Executable?

Windows question:

In an app I’m working on it has the option to leverage GhostScript, but it does not always know where / if GhostScript has already been installed by the user. In the case where the user already has it installed, I need to know the path to their copy of “gswin32c.exe” - which varies by GS version they installed. In the case where they have not installed GS, I prompt them to do so.

So, if they have already installed GS, how can I ask the OS for the path to gswin32c.exe?

Looks like I can execute “dir gswin32c.exe /s” from the root of the C drive in a shell, and then parse the output. That’s a little too kludgy to me, though. Anyone have a better way? Registry settings?

https://forum.xojo.com/34123-best-way-to-know-if-a-command-line-tool-is-installed