C# Application Scanning

半城伤御伤魂 提交于 2019-12-12 05:14:42

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!