lankabeta
lankabeta

Reputation: 91

File path of .exe File in windows 7

I am working in a C++ project. I need to obtain the path of a installed software. (Eg. skype.exe) Is there any way to find the path via C++ coding or via Widows command prompt

Upvotes: 1

Views: 924

Answers (2)

Gabe
Gabe

Reputation: 86688

It's in the App Paths registry key. For skype.exe you would look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\skype.exe

You can call the standard Win32 API RegQueryValue to read it.

Upvotes: 1

tenfour
tenfour

Reputation: 36896

Depends what you are needing it for, and how generic you want it.

  1. You can use GetEnvironmentVariable to get the PATH variable, and search these paths.
  2. You can use the App Paths registry key, as Gabe says. See also...
  3. Usually there are pretty clear application-specific ways to find the path via the registry. Either via the HKLM/Software key or Uninstall. Careful with localization and hard-coding application names...
  4. If you are just trying to launch the app, ShellExecute doesn't need the full path, it works almost like the "run" dialog box in the start menu.

Upvotes: 1

Related Questions