I'm fairly new to the Windows API. I'm trying to figure out how to block system shutdown. I figured out about `SERVICE_CONTROL_PRESHUTDOWN`. Not exactly how to use it yet, but I was planning to do something along the following lines as [HandlerEx](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683241(v=vs.85).aspx):

```
DWORD WINAPI serviceHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
{
    switch (dwControl)
    {
    case SERVICE_CONTROL_PRESHUTDOWN:
        while (1)
            Sleep(1000);
    }
    return NO_ERROR;
}

```

But A.) I'm not sure if I'm reading MSDN right, and implementing this `serviceHandler` correctly, and B.) Is there a better way of doing this. I essentially need this application to not allow shutdown unless it was forcibly by holding down the powerbutton.