Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
I'm working on a program where I allow a user change the windows logon screen background.

I'm done with it but I was wondering if I could just allow the user at any point regardless of if my application is running just press 'CTRL + SHIFT + >' and have the program change it's background.

I've added switches and the program has a service that changes the picture depending on the setting of the user.

I've googled this but all I can find is WindowsHook or something. This seems like a long shot and I'm looking for options before I start that. I want something like on windows whre you can just view the properties of a shortcut and assign a global key to it. Can this be done via the registry. Thanks.

What you need is really the Windows Hook. The problem is, in this case, this is the global Windows Hook, and, according to Microsoft documentation, you cannot set up a global hook using just C# or .NET programming. The global hook requires that you install it in a separate native (unmanaged) DLL. If you do this, load this DLL in your .NET application and embed some kind of communication between the DLL and your .NET application in the DLL itself, because you can alway use a DLL method via P/Invoke.

Please see:[^].

If you need to learn P/Invoke, start from here:[^],[^].

This CodeProject can also be useful: Essential P/Invoke[^].

One alternative to P/Invoke is to use C++/CLI mixed-mode (managed+unmanaged) project. This project could build a DLL required by the global hooks, but it can contain some managed wrapper CLI code, so, from the standpoint of your .NET application, you can use it as a regular .NET assembly, that is, reference it. Please see:[^],[^],[^],[^].

Share this answer
BillW33 30-Jul-12 12:39pm    
Nice answer, +5
Sergey Alexandrovich Kryukov 30-Jul-12 12:53pm    
Thank you,
I was looking into WindowsHook but I found this class here that seems to do exactly that. Thanks.
Share this answer
Akinmade Bond 27-Aug-12 6:44am    
Check this link on CodeProject which shows how to handle this on a larger scale.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900