简体   繁体   English

在启动和进程间通信方面提升运行

[英]Running Elevated on Startup & Inter Process Communication

I am building a program that logs 3D processes in the background. 我正在构建一个在后台记录3D流程的程序。 Some of them are running as administrator and I need to run elevated to capture those. 其中一些正在以管理员身份运行,我需要以更高的权限运行以捕获这些。 I am using psapi EnumProcesses with p/invoke. 我正在使用p / invoke的psapi EnumProcesses。 My question now is: how do I architect this to have the program: 我现在的问题是:如何构建该程序以使其具有以下功能:

  • start on user login 从用户登录开始
  • capture processes with elevated rights 捕获权限较高的过程
  • Have UI and TaskIcon present 有UI和TaskIcon
  • Able to restart / shutdown my program 能够重新启动/关闭我的程序

I looked at TaskScheduler solutions but there seem to be issues with launching a UI and the TaskBar icon might not show up, so that seems to be no solution, at least in the way suggested. 我查看了TaskScheduler解决方案,但是启动UI似乎存在问题,并且TaskBar图标可能不会显示,因此,至少以建议的方式,这似乎不是解决方案。

I have seen people recommend a separate process to run as task / service and then communicate with it. 我见过人们建议将一个单独的过程作为任务/服务运行,然后与之通信。 If this is a better and recommended solution, what is the recommended way to communicate with the other process in C#? 如果这是一个更好且推荐的解决方案,那么与C#中的其他进程进行通信的推荐方法是什么? I have seen people recommend named pipes and RPC. 我见过有人推荐命名管道和RPC。

So in summary, my question is, how do I architecture this the proper ".NET (4.6) / C# on Windows 10" way? 因此,总而言之,我的问题是,如何正确构建“ Windows 10上的.NET(4.6)/ C#”方式?

Some ideas: 一些想法:
Start the program after user login: 用户登录后启动程序:
You should explore windows Startup folder or registry HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run 您应该浏览Windows启动文件夹或注册表HKEY_CURRENT_USER \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Run
capture processes with elevated rights 捕获权限较高的过程
Check this ; 检查这个 ;
UI and TaskIcon/Able to restart / shutdown my program UI和TaskIcon /可以重新启动/关闭程序
I would go for an UI application that starts in the systray and communicates with the Process Monitor using WCF for more complex data migration or EventWaitHandle if you just need signal migration. 我将选择一个从systray中启动并使用WCF与Process Monitor进行通信的UI应用程序,以进行更复杂的数据迁移或EventWaitHandle(如果您只需要信号迁移)。

As mentioned before, I would go for 2 applications: 1 acting as your monitor service (UI-less) and a client application with UI. 如前所述,我将使用2个应用程序:1个充当监视器服务(无UI)和带UI的客户端应用程序。 The communication between these processes depends greatly on your needs, but WCF might be a good choice for complex data or EventWaitHandle for just sending/receiving signals. 这些过程之间的通信在很大程度上取决于您的需求,但是对于复杂数据或仅用于发送/接收信号的EventWaitHandle,WCF可能是一个不错的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM