473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

[?] ERROR_HOOK_NEEDS_HMOD during installing system hook

Hi, i want to do system hook WH_SYSMSGFILTER,
my code is:

IntPtr hMod =
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly ().GetModules()[0]);
//install hook
hSysMsgHook = Api.User32.SetWindowsHookEx(WH_SYSMSGFILTER,
SysMsgHookProcedure, hMod, 0);
//If SetWindowsHookex fails.
if (hSysMsgHook == 0)
{
int errorCode = Marshal.GetLastWin32Error();
//do cleanup
Stop(false, false, true, false);
//Initializes and throws a new instance of the Win32Exception class with
the specified error.
throw new Win32Exception(errorCode);
}
hMod is valid but the api return code is ERROR_HOOK_NEEDS_HMOD!
other types of hook like WH_KEYBOARD_LL or WH_MOUSE_LL works fine!
my machine is windows vista
what's wrong?
Thanks

Nov 22 '07 #1
2 3636
>Hi, i want to do system hook WH_SYSMSGFILTER,

You can't implement global system hooks in managed code (with the
exception of the _LL types). Choose another language that compiles to
native code and that doesn't require any runtime library to run.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 22 '07 #2
the bottom of this article

http://support.microsoft.com/default.aspx/kb/318804

explains that .net applications cannot implement global system hooks
hope this helps

--iwdu15
Nov 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex | last post by:
I am trying to determine if C# has the capabilities to listen for system events when the application does not have the window's focus. I am writing a windows application that I would like to run...
1
by: Tim Mohler | last post by:
All - I have a script that provides a web page interface to various system utilities. Once the user has selected the utility and input various parameters, it calls itself with a different method...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
2
by: Dave A | last post by:
I have an application that runs in the system tray (taskbar notification area) and it runs at startup. Occasionally I need to release a new version. I have created a deployment project in .Net. ...
1
by: Michael Roper | last post by:
Well, actually I'm not sure that's what I need. What I'd like to do is write an app for the tray that can monitor any app that gets launched and do a 'window size and position' on it based on...
6
by: gregory_may | last post by:
I am dying trying to get the GinaStub example to work at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpginastubsample.asp Any help is greatly...
0
by: Low Chen | last post by:
I had a problem at the end of installing visual basic 6.0 enterprice version. During "Update the system", the "Microsoft Setup Tool" had a problem. The problem said that "Microsoft Setup Tool" got...
10
by: MLH | last post by:
My A97 runtime installations are sometimes paused during the install process prompting user with messages saying the files are in use. Generally, I tell them to click IGNORE. Although I haven't...
22
by: schneider | last post by:
I need to hook the system mouse down event. I'm trying to replicate how a context menu hides when the mouse clicks outside of the control. Thanks, Schneider
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.