Okay, some explanation is in place here. Your service will have it's own thread and will be receiving messages from the system. If you don't provide an execute event, the service will use it's internal

It's a common mistake, though. In Windows 3.11 it would be valid because anything less than 33 was reserved for the system. These days however the LoadLibrary either returns 0 on an error or any other value if it's valid.

Actually, service applications are quite easy in Delphi, but only run on Windows versions based on NT technology. Basically, after File/New, then selecting "Service application" you already have a working system service. All you have to do is run it with the parameter /Install to install it or with /Uninstall to uninstall it.

System services can be displayed if you go to: 'Settings/Control Panel/Administrative tools/Services' where you can manage them. Some start automatically, other manually and a few might be disabled. Some will be running, others have stopped. Most services just run in the background but a few interact with the desktop. Services aren't that popular at the moment, though. They're a bit complex and hard to debug and it's almost impossible to find some good examples for it. But in general, some tips:

If you've done the file/new... stuff, you get a service module with several properties and events. The most interesting properties are the DisplayName, Interactive, ServiceType, StartType and perhaps the AllowPause/AllowStop properties. From the events, the OnStart, OnStop, OnPause and OnContinue are the most important ones, but as an alternative you could also use the OnExecute event instead.
If you use the OnExecute event for your service, your service will end when it's finished with this event. Thus in general you'd be using an everlasting loop in your event, leaving only when the service is terminated. I prefer to use the OnStart/OnStop methods instead, though. I create a separate thread in the OnStart and terminate it again in the OnStop. This way the service itself is more responsive too. (Basically, if your OnExecute event doesn't check for new messages, your service won't respond on anything.)

Since it seems you're generating a keyboard hook here, you actually have nothing to worry about, I think. In the OnStart you just call:
SetHook(hSetHook)(True);
And in the OnStop you call:
SetHook(hSetHook)(True);
In the OnCreate you open the hook.dll library which you close again in the OnDestroy. You do not need to call Sleep anywhere either since the service will run until stopped. The service might also start up automatically after reboot, thus it might be active before a user logs in. (But it won't capture the logon password!)

With system services you will have problems with access rights and security. And it can also happen that your service just freezes and there's no way to stop it. Which can be a real pain... You have to be a bit careful with them. And debugging a system service? I just let the service write log messages to a textfile instead of running it through the debugger. It's easier...

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Okay, some explanation is in place here. Your service will have it's own thread and will be receiving messages from the system. If you don't provide an execute event, the service will use it's internal messagehandler. However, you can override this by defining an execute event in which case you control exactly what your service is doing. But in general this execute method is rarely used, except by the less experienced developers.
If you use an Execute method, you need to call 'ServiceThread.ProcessRequests()' quite regularly to have the service process any incoming messages.

Sometimes, when I need the service to perform some background task, I don't use the execute method but just generate a new thread that will do the background task. That way I still don't have to use the Execute method. But you don't need this because you just add a keyboard hook and this will be called whenever a keyboard message is received.

Oh, btw. You're calling SetHook with the parameter to "True" in both the Start and stop method. Is that logical?

I removed ServiceExecute and change the parameter of SetHook in stop method to "False" but it did not anyway function. I run ServiceProject.exe and then reboot. After writing some words in the Notepad I could not find any 'keyboad.txt' in the same folder of the ServiceProject.exe. But it should be there according to WriteToLog of the Hook.dpr.

Actually, the problem is that the service program does not run and load the library. Because, after I started the service program I tried to delete it and the library: it was successful... The same was when I've done reboot...
nvs28111962

Objective:
- This article will help user in how to convert their numeric value become words.
How to use
1. You can copy this code in your Unit as function
2. than you can perform your function by type this code
The Code
(CODE)
The Im…

Introduction
Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview. I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg).
If you're looking for how to monitor bandwidth using netflow or packet s…