[英]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: 编辑:
The term you need to use is hook : the interception of some operation on windows. 您需要使用的术语是hook :拦截Windows上的某些操作。 Eg.
例如。 " Is it possible to hook the creation of windows globally so I can control where the windows are placed on the screen? "
“ 是否可以全局地挂起窗口的创建,以便我可以控制窗口在屏幕上的放置位置? ”
There is a direct way in the kernel: PsSetCreateProcessNotifyRoutine
内核中有一种直接方法:
PsSetCreateProcessNotifyRoutine
There are helpers in user mode (eg. EasyHook ), but these require injected your code into each process (which anti-malware tools are likely to object to). 在用户模式下有助手(例如EasyHook ),但是这些助手需要将您的代码注入到每个进程中(反恶意软件工具可能会反对)。
But you should still start out by looking for better approaches to you underlying problem. 但是,您仍然应该从寻找更好的解决潜在问题的方法开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.