创建应用程序库WPF表单C#.NET [英] Creating a App Library WPF Form C# .NET

查看:70
本文介绍了创建应用程序库WPF表单C#.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好CodeProject的用户!



所以我最近的项目已成为Exe Library,这意味着理论上用户将能够按按钮&它会找到所有的可执行文件。



我将采取哪种方式来开始这段旅程。

(我的想法是这样的。 )

http://imgur.com/WpXIXs4



我必须使用特定的API吗? (如果我使用的是WIndows API,请阅读它可以更容易的地方)



DirectoryInfo会让我受益吗?



你会使用什么循环?



我想说我不是在寻找具体的代码我只是在寻找一个人来告诉我去哪儿方式&我应该提供什么样的信息?不应该寻找。

任何答案都非常感谢。

谢谢!

Hello fellow users of CodeProject!

So my most recent project has become a "Exe Library" which means that in theory the user will be able to Press a button & it will find all the executables.

Which way would would I take to start this journey.
(My idea is something like this.)
http://imgur.com/WpXIXs4

Would I have to use a specific API? (Read somewhere that it could make easier if I used a WIndows API)

Would "DirectoryInfo" benefit me at all?

What Loops would you use?

I would like to say that im not looking for any code in specific I am simply looking for a someone to tell me what way to go & what kind of information I should & should not look for.
Any answer is highly appreciated.
Thanks!

推荐答案

并非一切都很清楚在你的解释中,但我会开始回答。



* .exe文件不是所有可执行文件,但如果这就是你所需要的,您可以使用方法 System.IO.Directory.GetFile 获取整个文件集,这三个方法中的第三个方法,一个 SearchOption

https://msdn.microsoft.com/en-us/library/system.io.directory.getfiles%28v=vs.110%29.aspx [ ^ ],

https://msdn.microsoft .com / zh-cn / library / ms143316(v = vs.110).aspx [ ^ ],

https://msdn.microsoft.com/en-us/library /ms143448%28v=vs.110%29.aspx [ ^ ]。



SearchOption.AllDirectories 通过递归目录一次性为您提供所有文件列表。



现在,所有已安装的文件完全不同并且全部运行在你的机器上是另一回事。如果你的意思是上述所有问题都与这两个问题无关,那你就完全正确了。



让我们从全部运行开始吧。不,这不是一个正确提出的问题。文件未运行。运行是应用程序和进程。您可以获得系统中的所有流程:

https://msdn.microsoft.com/en-us/library/1f3ys1f9(v=vs.110).aspx [ ^ ]。



然后你可以获取返回进程的每个实例,类型为 System.Diagnostics.Process ,并获取每个进程的所有信息: https://msdn.microsoft.com/en-us/library/system.diagnostics.process% 28v = vs.110%29.aspx [ ^ ]。



现在,我们来看文件。不,这不仅仅是文件。您必须了解每个进程使用一个或多个可执行文件,而可执行文件不是* .exe。它可能是* .dll,还有更多。真正的可执行文件是PE文件。您需要了解它的真实含义: https://en.wikipedia.org/wiki/Portable_Executable [ ^ ]。



要获取所有信息,您需要获取每个进程的属性, Process.Modules Process.MainModule

https: //msdn.microsoft.com/en-us/library/system.diagnostics.process.mainmodule(v=vs.110).aspx [ ^ ],

https://msdn.microsoft.com/en -us / library / system.diagnostics.process.modules(v = vs.110).aspx [ ^ 然后,从模块中,你可以来到可执行文件:

https://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule%28v= vs.110%29.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule.filename(v = vs.110)的.aspx [ ^ ],

(并查看其他房产)。



我想暂时停在这里。对于单个答案来说绰绰有余。请告诉我您是否仍想了解已安装的应用程序(同样,不是文件,而是进程;应用程序)。我想警告你:这个话题要困难得多,同时也不那么重要,不那么重要,也不是特定于平台。我不确定你真的需要列出它。但如果你认为你需要,让我在一个单独的答案中讨论它。这个已经有点太多了。



-SA
Not everything is clear in your explanation, but I'll start to answer.

The *.exe files is not all the "executable files", but if this is all you need, you can obtain the whole set of the file using the method System.IO.Directory.GetFile, the 3rd method of these three, the one with SearchOption:
https://msdn.microsoft.com/en-us/library/system.io.directory.getfiles%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/ms143316(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/ms143448%28v=vs.110%29.aspx[^].

SearchOption.AllDirectories gives you the all the list of files at once, taken by recursing the directories.

Now, "all the file installed" is completely different thing and "all running on your machine" is another different thing. If you meant that all of the above is irrelevant to both of these problem, you were perfectly right.

Let's start with "all running". No, this is not a correctly posed problem. Files are not running. Running are applications and processes. You can get all processes in the system:
https://msdn.microsoft.com/en-us/library/1f3ys1f9(v=vs.110).aspx[^].

Then you can take each instance of the returned processes, of the type System.Diagnostics.Process, and get all the information of each process: https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx[^].

Now, we are coming to files. No, it's not just the file. You have to understand that each process used one or more executable files, and executable file is not *.exe. It could be *.dll, and a lot more. Real "executable file" is the PE file. You need to understand what it really is: https://en.wikipedia.org/wiki/Portable_Executable[^].

To get all the information, you need to get the properties of each process, Process.Modules and Process.MainModule:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainmodule(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.modules(v=vs.110).aspx[^].

Then, from module, you can come to executable files:
https://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule.filename(v=vs.110).aspx[^],
(and see other properties).

I want to stop here for now. It's more than enough for a single answer. Please tell me if you still want to know about "installed applications" (again, not files, but not processes; applications). I want to warn you: this topic is much harder, and at the same time, much less important, less fundamental and more platform-specific. I'm not sure you really need to list it. But if you think you need, let me discuss it in a separate answer. This one is already a bit too much.

—SA


顺便说一句,关于你提到的安装的应用程序。我发现这篇CodeProject文章几乎解释了所有主题: http://www.codeproject.com/Tips/782919/Get-List-of-Installed-Applications-of-System-inCs [ ^ ]。



首先要明白的是:这不是已安装的文件列表,甚至不是应用程序。这是已安装产品的列表。阅读文章,您将了解每件商品所获得的信息。



-SA
By the way, about "installed applications" you mentioned. I found this CodeProject article which explains pretty much all the topic: http://www.codeproject.com/Tips/782919/Get-List-of-Installed-Applications-of-System-in-Cs[^].

First thing to understand: this is not the list of installed "files" and not even application. This is the list of installed products. Read the article, and you will understand what information you get with each item.

—SA


这篇关于创建应用程序库WPF表单C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆