Hi Techies,
I have some applications which I want to launch when user presses specific keys from the keyboard, and for this I want to use WndProc method.
I am successful in this in a WinForms application. I want to develop a Windows Service to achieve this.
I get the following errors while trying to use the code in a Windows Service.
1. RegHotKeys.CreateParams : no suitable method found to override
2. RegHotKeys.WndProc(ref Message) : no suitable method found to override
3. ServiceBase does not contain a definition for WndProc
4. ServiceBase does not contain a definition for CreateParams
Following is the code snippet:
- protected override void WndProc(ref Message keyPressed)
- {
- Keys keyData = ((Keys)((int)((long)keyPressed.WParam))) | Control.ModifierKeys;
-
- if (keyPressed.LParam.ToInt32() == hotKey1)
- {
-
- }
- else if (keyPressed.LParam.ToInt32() == hotKey2)
- {
-
- }
- else if (keyPressed.LParam.ToInt32() == hotKey3)
- {
-
- }
- else if (keyPressed.LParam.ToInt32() == hotKey4)
- {
-
- }
-
- base.WndProc(ref keyPressed);
- }
-
- protected override CreateParams CreateParams
- {
- get
- {
- var cp = base.CreateParams;
- cp.ExStyle |= 0x80;
- return cp;
- }
- }
So can anybody suggest what could be the possible solution to this please?