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 :)
//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);