If you have ever wanted to create a Windows Service program using PowerBuilder then you have come to the right place. PBNIServ will allow you to easily create a service with PowerBuilder 9 or greater. No complex API calls to worry about, it just works right!
What is a Windows Service?
A Windows Service is a program that has no user interface and is started automatically when Windows starts. The program continues running until Windows is shut down. There does not need to be anyone logged on to Windows for the program to run. A service program is ideal for programs that run on a server machine without user intervention. This would include programs that run reports on a schedule or periodically processing files.
What is PBNIServ?
PBNIServ is a generic Windows Service program written in C. It uses the PBNI (PowerBuilder Native Interface) feature introduced in PowerBuilder 9 to execute functions within a non-visual userobject. A base service object is included that you inherit objects from. The C program calls the predefined functions and your PowerBuilder code is executed.
When your service is installed, the library file and userobject name are given and are stored in the registry. The C program reads these values from the registry and generically loads the userobject and executes the appropriate functions. This design allows you to create a true Windows Service program entirely in PowerBuilder!
Also included is a Service Control application. It has functions to start, stop, pause and resume services. You can also use it to send user defined control codes to the service.
Why do I need PBNIServ to create a service?
A true Windows Service program uses callbacks. A callback is when you pass a function in your program as an argument to a Windows API function. The API function then makes calls to your function. PowerBuilder does not support callback functions. There are 2 callback functions involved in writing a service program, StartServiceCtrlDispatcher and RegisterServiceCtrlHandlerEx.
How do I create a service with PBNIServ?
Creating a service with PBNIServ is very easy. There are no Windows API functions to call, just 100% pure PowerBuilder code. See how easy it is by downloading the free demo and giving it a try yourself.
Operating System compatibility
PBNIServ was originally developed on Windows XP. It has been tested on Windows 2000, Windows XP, Windows Vista 32bit, Windows 7 64bit, Windows 8, and Windows 10. I have not tried it on Windows 2003 Server or higher. I am not aware of anything that would prevent it from working. Windows 2000 does not support the of_sessionchg function.