问题
I want to scan and get all the Application files in my computer.
I know how to get them, but I want only the applications which are Executable (except for Installers).
Basically, what I want is the same function steam uses. Example:

回答1:
If you want to get the list of installed applications on your system, you can query the registry. Refer to Get installed applications in a system for an example.
回答2:
You can use this code to find all exes recursively in a directory
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\Program Files");
var exeFiles = dirInfo.EnumerateFiles("*.exe", SearchOption.AllDirectories);
foreach ( var exeFile in exeFiles )
{
Console.WriteLine( exeFile );
}
Depending on you definition of executable you might have to also do *.com
, *.bat
etc etc. There is no way to distinguish between an installer exe vs regular exe file though. You might have to apply some heuristics
来源:https://stackoverflow.com/questions/8954461/c-sharp-application-scanning