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. PBNIServ supports PowerBuilder version 9, 10 and 10.5.
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.
Operating System compatibility
PBNIServ was developed on Windows XP. It has been tested on Windows 2000 and Windows XP. Windows 2000 does not support the of_sessionchg function. I have not tried it on Windows 2003 Server or Windows Vista. I am not aware of anything that would prevent it from working. If you have issues or success on these operating systems, please contact me.