简体   繁体   English

在Windows 8中启动任何应用程序时,如何启动我的C#应用​​程序?

[英]How to launch my C# application when any application starts in Windows 8?

I want to launch my application, like the windows security prompt, before any application is launched in Windows 8. Is there any event handler, which gets notified whenever any application is launched? 我想在Windows 8中启动任何应用程序之前启动我的应用程序,例如Windows安全性提示。是否有任何事件处理程序,每当启动任何应用程序时都会得到通知?

My use Case : I want an App similar to a child lock(Lets call it myCustomApp). 我的用例:我想要一个类似于儿童锁的应用程序(我们称其为myCustomApp)。 When any user runs a game(say Solitare), i want myCustomApp to check the process name, and kill the process immediately. 当任何用户运行游戏时(例如Solitare),我希望myCustomApp检查进程名称,并立即终止该进程。

PS : i am quite new to programming. PS:我是编程新手。

Thanks in advance! 提前致谢!

Is there any event handler, which gets notified whenever any application is launched? 是否有事件处理程序,每当启动任何应用程序时都会得到通知?

Yes: you get use WMI events to detect new instances of Win32_Process . 是的:您可以使用WMI事件来检测Win32_Process新实例。

But these are created with process creation, not before. 但是这些是通过流程创建而不是之前创建的。

Doing something between the call to ProcessCreate that creates the new process, and the process actually being created is going to be, at best hard (you might need to do it in the kernel), but quite possibly impossible. 在创建新进程的ProcessCreate调用与实际创建的进程之间要做一些事情,至多是很难的(您可能需要在内核中完成),但是可能是不可能的。

Why do you want to do this? 为什么要这样做? What problem are you trying to solve? 您要解决什么问题? This really does sound like an XY problem . 这确实听起来像是XY问题

Edit: 编辑:

But you should still start out by looking for better approaches to you underlying problem. 但是,您仍然应该从寻找更好的解决潜在问题的方法开始。

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

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