I'm writing a service in "C" and I'd like to display a warning window once the user tries to stop the service ( With "OK" and "Cancel" Buttons ).
Is there any specific windows API available to achieve this? Any other simple ways are there to achieve??
No, this is not possible. Windows services are unable to interact directly with the user's desktop, so they will be unable to show a user interface of any kind.
This shouldn't really be a big deal, though. You have to have adequate permissions to stop and start a service, and by default, only Administrators have those rights. If you don't want users inadvertently stopping your service, then you should take advantage of permissions to solve that problem for you.
I just learned the hard way that any calls made to the UI from a service will cause it to hang. MSDN does have a page here on work arounds.
You stop a service with Service control panel; your service normally doesn't have access to this control panel process, so you can't override it's UI and present a dialog asking OK/Cancel.
If you don't want anybody to be able to stop the service, just tell the service manager that you don't accept stop messages. You could instead provide an application that stops the service (using some form of IPC) and that application could present as many warning messages as you wanted.
On the other hand, this will annoy your users, and it is unlikely to be necessary. By default, only administrators can stop services, and people are unlikely to try to stop your service without a good reason.