Set Hot key for windows service

Hi
It is my first time I want to develop a windows service in c++. At first I need to set a hot key for my service that whenever the combination is pushed a function will run.
I found the code below that works fine in console application, but when I run it as service, no message is returned by peekmessage.
Any advice is appreciated :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//in the start part of service
RegisterHotKey(NULL,100,MOD_SHIFT,'F')!=0
//in the main function of service
//the main function of service is a while loop that continue for running until the stop //command is recieved
MSG msg={0};
if (PeekMessage(&msg, NULL , WM_HOTKEY, WM_HOTKEY,PM_REMOVE)!=0)
{
switch(msg.message)
	{
		case WM_HOTKEY: 
		switch(msg.wParam)
		{
			case 100:
			LogWork("The hotkey was recognized\n");
			break;
		}
	}
}
//in the stop part of service
UnregisterHotKey(NULL,100);
Last edited on
I found a lot of c++ answer here. but nobody answer my question!!!!!!
Please Help :(
Topic archived. No new replies allowed.