What are the main differences (how it works/dependencies/purpose/minimal requirements) between SetWindowsHookEx and SetWinEventHook ?
I'm interested in intercepting events related to running windows applications from a Windows service using C#/.Net.
SetWindowsHookEx
sets low-level hooks which can intercept and re-write several system-wide events and messages (like capturing and re-writing keyboard input).
SetWinEventHook
allows you to listen to Window events without having a window. It's higher level and less intrusive to the system.
Neither of this is required for running other applications from a service. Look at System.Diagnostics.Process
(built into .Net) or RunProcess
on NuGet
If i understand you correctly, you want to use a service that you created to intercept the messages that are flowing between the OS and running Windows applications.
If that is the case your best choice is SetWindowsHookEx, this will create a system level hook which you will have to filter pass on to other appliations. You should note that this requires you to also build c++ .dll file from which you would call the SetWindowsHookEx function. Be very careful when coding because an error could lock up the entire system and you will need a restart to get things back to normal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With