当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Hook for API function GetSystemMetrics

问题描述:

Please help me create hook for AP.I function GetSystemMetrics.

I want that when some app(for example calc.exe) call GetSystemMetrics they receive my value(for example 500x500) and other apps get correct screen size.

And if somebody can tell me how can I do this use C# and .net CF 2.0 I'll be very happy.

Thanks and hope for you help.

网友答案:

I don't think it's possible to do in C#/.NET without writing any native code. However, the good news is that there is a wonderful library called madCodeHook which is really easy to use. Take a look at http://madshi.net/

网友答案:

You can't do that, even in native code (at least not without ugly, bad-idea, vtable/kernel memory hacks that may or may not continue to work across versions of the OS). GetSystemMetrics calls down to the OS to get information about the platform. There's no way, short of recompiling the OS and changing those values, that you can "override" thse values and get the OS to report other numbers (unless, of course, the OS was already built in such a way that those numbers came from somewhere your app can modify - like the registry).

EDIT

Based on your comments, your actual problem is that you're trying to create some form of "taskbar" type application and you'd like other apps outside of your control to not overlay your taskbar when they maximize. This is exactly how the exisiting Explorer taskbar works, so my suggestion is to go look in the default shell source code and see how it is accomplished there.

The end result is likely going to be that you will either clone the existing shell code and modify the existing taskbar to meet your needs, or you'll create an entirely new shell application that has the behavior you want, but you almost certainly are going to have to replace the shell, and that can only be done with native code.

分享给朋友:
您可能感兴趣的文章:
随机阅读: