diff --git a/reference/win32service/constants.xml b/reference/win32service/constants.xml new file mode 100644 index 0000000000..790a102075 --- /dev/null +++ b/reference/win32service/constants.xml @@ -0,0 +1,444 @@ + + + +
+ &reftitle.constants; + &extension.constants; + + + + WIN32_SERVICE_CONTROL_CONTINUE + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTROL_INTERROGATE + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTROL_PAUSE + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTROL_STOP + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTROL_HARDWAREPROFILECHANGE + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTROL_POWEREVENT + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTROL_SESSIONCHANGE + (integer) + + + + + + + + + + + WIN32_ERROR_CALL_NOT_IMPLEMENTED + (integer) + + + + + + + + + + + WIN32_NO_ERROR + (integer) + + + + + + + + + + + WIN32_SERVICE_RUNNING + (integer) + + + + + + + + + + + WIN32_SERVICE_STOPPED + (integer) + + + + + + + + + + + WIN32_SERVICE_STOP_PENDING + (integer) + + + + + + + + + + + WIN32_SERVICE_WIN32_OWN_PROCESS + (integer) + + + + + + + + + + + WIN32_SERVICE_INTERACTIVE_PROCESS + (integer) + + + + + + + + + + + WIN32_SERVICE_STOPPED + (integer) + + + + + + + + + + + WIN32_SERVICE_START_PENDING + (integer) + + + + + + + + + + + WIN32_SERVICE_STOP_PENDING + (integer) + + + + + + + + + + + WIN32_SERVICE_RUNNING + (integer) + + + + + + + + + + + WIN32_SERVICE_CONTINUE_PENDING + (integer) + + + + + + + + + + + WIN32_SERVICE_PAUSE_PENDING + (integer) + + + + + + + + + + + WIN32_SERVICE_PAUSED + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_NETBINDCHANGE + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_PARAMCHANGE + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_PAUSE_CONTINUE + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_SHUTDOWN + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_STOP + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_HARDWAREPROFILECHANGE + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_POWEREVENT + (integer) + + + + + + + + + + + WIN32_SERVICE_ACCEPT_SESSIONCHANGE + (integer) + + + + + + + + + + + WIN32_SERVICE_FILE_SYSTEM_DRIVER + (integer) + + + + + + + + + + + WIN32_SERVICE_KERNEL_DRIVER + (integer) + + + + + + + + + + + + WIN32_SERVICE_WIN32_SHARE_PROCESS + (integer) + + + + + + + + + + + WIN32_SERVICE_RUNS_IN_SYSTEM_PROCESS + (integer) + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/reference/win32service/functions.xml b/reference/win32service/functions.xml new file mode 100644 index 0000000000..0144333966 --- /dev/null +++ b/reference/win32service/functions.xml @@ -0,0 +1,8 @@ +&reference.win32service.functions.win32-create-service; +&reference.win32service.functions.win32-delete-service; +&reference.win32service.functions.win32-get-last-control-message; +&reference.win32service.functions.win32-query-service-status; +&reference.win32service.functions.win32-set-service-status; +&reference.win32service.functions.win32-start-service-ctrl-dispatcher; +&reference.win32service.functions.win32-start-service; +&reference.win32service.functions.win32-stop-service; diff --git a/reference/win32service/functions/win32-create-service.xml b/reference/win32service/functions/win32-create-service.xml new file mode 100644 index 0000000000..e029bc7ca7 --- /dev/null +++ b/reference/win32service/functions/win32-create-service.xml @@ -0,0 +1,202 @@ + + + + + + win32_create_service + Creates a new service entry in the SCM database + + + &reftitle.description; + + longwin32_create_service + arraydetails + stringmachine + + + + &reftitle.parameters; + + + + details + + + An array of service details: + + + service + + The short name of the service. This is the name that you + will use to control the service using the net + command. The service must be unique (no two services can share the + same name), and, ideally, should avoid having spaces in the name. + + + + display + + The display name of the service. This is the name that you + will see in the Services Applet. + + + + + user + + + The name of the user account under which you want the service to + run. If omitted, the service will run as the LocalSystem account. + If the username is specified, you must also provide a password. + + + + + password + + + The password the corresponds to the user. + + + + + path + + + The full path to the executable module that will be launched when + the service is started. If omitted, the path to the current PHP + process will be used. + + + + + params + + + Command line parameters to pass to the service when it starts. + If you want to run a PHP script as the service, then the first + parameter should be the full path to the PHP script that you intend + to run. + + + + + load_order + + + Controls the load_order. This is not yet fully supported. + + + + + svc_type + + + Sets the service type. If omitted, the default value is + WIN32_SERVICE_WIN32_OWN_PROCESS. + Don't change this unless you know what you're doing. + + + + + start_type + + + Specifies how the service should be started. The default is + WIN32_SERVICE_AUTO_START which means the the + service will be launched when the machine starts up. + + + + + error_control + + + Informs the SCM what it should do when it detects a problem with + the service. The default is + WIN32_SERVER_ERROR_IGNORE. Changing this + value is not yet fully supported. + + + + + + + + + machine + + + The optional machine name on which you want to create a service. + If omitted, it will use the local machine. + + + + + + + + &reftitle.returnvalues; + + Returns &true; on success, otherwise returns a win32 error code. + + + + + &reftitle.examples; + + + A <function>win32_create_service</function> example + + Any text that describes the purpose of the example, or + what goes on in the example should go here (inside the + + 'dummyphp', + 'display' => 'sample dummy PHP service', + 'params' => __FILE__ . ' run', +)); +debug_zval_dump($x); +?> +]]> + + + + + + + + + &reftitle.seealso; + + + win32_delete_service + + + + + + + + diff --git a/reference/win32service/functions/win32-delete-service.xml b/reference/win32service/functions/win32-delete-service.xml new file mode 100644 index 0000000000..44f56ca2ad --- /dev/null +++ b/reference/win32service/functions/win32-delete-service.xml @@ -0,0 +1,111 @@ + + + + + + win32_delete_service + Deletes a service entry from the SCM database + + + &reftitle.description; + + longwin32_delete_service + stringservicename + stringmachine + + + + Attempts to delete a service from the SCM database. Administrative + privileges are required for this to succeed. + + + This function really just marks the service for deletion. If other + processes (such as the Services Applet) are open, then the deletion will be + deferred until those applications are closed. If a service is marked for + deletion, further attempts to delete it will fail, and attempts to create a + new service with that name will also fail. + + + + + &reftitle.parameters; + + + + servicename + + + The short name of the service. + + + + + machine + + + The optional machine name. If omitted, the local machine will be used. + + + + + + + + &reftitle.returnvalues; + + Returns &true; on success, or a win32 error code on failure. + + + + + &reftitle.examples; + + + A <function>win32_delete_service</function> example + + Deletes the dummyphp service. + + + +]]> + + + + + + + + + + + + diff --git a/reference/win32service/functions/win32-get-last-control-message.xml b/reference/win32service/functions/win32-get-last-control-message.xml new file mode 100644 index 0000000000..2239f92c41 --- /dev/null +++ b/reference/win32service/functions/win32-get-last-control-message.xml @@ -0,0 +1,66 @@ + + + + + win32_get_last_control_message + Returns the last control message that was sent to this service + + + &reftitle.description; + + longwin32_get_last_control_message + + + + + Returns the control code that was last sent to this service process. + When running as a service you should periodically check this to determine if + your service needs to stop running. + + + + + &reftitle.returnvalues; + + Returns a control constant; one of WIN32_SERVICE_CONTROL_CONTINUE, + WIN32_SERVICE_CONTROL_INTERROGATE, + WIN32_SERVICE_CONTROL_PAUSE, + WIN32_SERVICE_CONTROL_STOP, + WIN32_SERVICE_CONTROL_HARDWAREPROFILECHANGE, + WIN32_SERVICE_CONTROL_POWEREVENT, + WIN32_SERVICE_CONTROL_SESSIONCHANGE. + + + + + &reftitle.seealso; + + + win32_start_service_ctrl_dispatcher + + + + + + + + diff --git a/reference/win32service/functions/win32-query-service-status.xml b/reference/win32service/functions/win32-query-service-status.xml new file mode 100644 index 0000000000..27bb4f5fb9 --- /dev/null +++ b/reference/win32service/functions/win32-query-service-status.xml @@ -0,0 +1,238 @@ + + + + + + win32_query_service_status + Queries the status of a service + + + &reftitle.description; + + mixedwin32_query_service_status + stringservicename + stringmachine + + + + Queries the current status for a service, returning an array of + information. + + + + + &reftitle.parameters; + + + + servicename + + + The short name of the service. + + + + + machine + + + The optional machine name. If omitted, the local machine will be used. + + + + + + + + &reftitle.returnvalues; + + Returns &false; on failure, otherwise returns an array consisting of the + following information: + + + + + ServiceType + + + The dwServiceType. + + + + + CurrentState + + + The dwCurrentState. + + + + + ControlsAccepted + + + Which service controls are accepted by the service. + + + + + Win32ExitCode + + + If the service exited, the return code from the process. + + + + + ServiceSpecificExitCode + + + If the service exited with an error condition, the service specific + code that is logged in the event log is visible here. + + + + + CheckPoint + + + If the service is shutting down, holds the current check point number. + This is used by the SCM as a kind of heart-beat to detect a wedged service + process. The value of the check point is best interpreted in + conjunction with the WaitHint value. + + + + + WaitHint + + + If the service is shutting down it will set WaitHint to a checkpoint + value that will indicate 100% completion. This can be used to + implement a progress indicator. + + + + + ProcessId + + + The windows process identifier. If 0, the process is not running. + + + + + ServiceFlags + + + The dwServiceFlags. + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reference/win32service/functions/win32-set-service-status.xml b/reference/win32service/functions/win32-set-service-status.xml new file mode 100644 index 0000000000..b308c84e87 --- /dev/null +++ b/reference/win32service/functions/win32-set-service-status.xml @@ -0,0 +1,81 @@ + + + + + + win32_set_service_status + Update the service status + + + &reftitle.description; + + boolwin32_set_service_status + intstatus + + + Informs the SCM of the current status of a running service. + This call is only valid for a running service process. + + + + &reftitle.parameters; + + + + status + + + The service status code, one of + WIN32_SERVICE_RUNNING, + WIN32_SERVICE_STOPPED, + WIN32_SERVICE_STOP_PENDING, + WIN32_SERVICE_START_PENDING, + WIN32_SERVICE_CONTINUE_PENDING, + WIN32_SERVICE_PAUSE_PENDING, + WIN32_SERVICE_PAUSED. + + + + + + + + &reftitle.returnvalues; + + &return.success; + + + + + + &reftitle.seealso; + + + win32_start_service_ctrl_dispatcher + + + + + + + + diff --git a/reference/win32service/functions/win32-start-service-ctrl-dispatcher.xml b/reference/win32service/functions/win32-start-service-ctrl-dispatcher.xml new file mode 100644 index 0000000000..6bb8d3461f --- /dev/null +++ b/reference/win32service/functions/win32-start-service-ctrl-dispatcher.xml @@ -0,0 +1,114 @@ + + + + + + win32_start_service_ctrl_dispatcher + Registers the script with the SCM, so that it can act as the service with the given name + + + &reftitle.description; + + boolwin32_start_service_ctrl_dispatcher + stringname + + + + When launched via the Service Control Manager, a service process is + required to "check-in" with it to establish service monitoring and + communication facilities. This function performs the check-in by spawning + a thread to handle the lower-level communication with the service control + manager. + + + Once started, the service process should continue to check-in with the + service control manager so that it can determine if it should terminate. + This is achieved by periodically calling + win32_get_last_control_message and handling the return + code appropriately. + + + + + + &reftitle.parameters; + + + + name + + + The short-name of the service, as registered by + win32_create_service. + + + + + + + + &reftitle.returnvalues; + + &return.success; + + + + &reftitle.examples; + + + A <function>win32_start_service_ctrl_dispatcher</function> example + + Any text that describes the purpose of the example, or + what goes on in the example should go here (inside the + + + +]]> + + + + + + + + &reftitle.seealso; + + + win32_get_last_control_message + + + + + + + + diff --git a/reference/win32service/functions/win32-start-service.xml b/reference/win32service/functions/win32-start-service.xml new file mode 100644 index 0000000000..9d741fd629 --- /dev/null +++ b/reference/win32service/functions/win32-start-service.xml @@ -0,0 +1,85 @@ + + + + + + win32_start_service + Starts a service + + + &reftitle.description; + + longwin32_start_service + stringservicename + stringmachine + + + + Attempts to start the named service. Usually requires administrative + privileges. + + + + + &reftitle.parameters; + + + + servicename + + + The short name of the service. + + + + + machine + + + Optional machine name. If omitted, the local machine is used. + + + + + + + + &reftitle.returnvalues; + + Returns WIN32_NO_ERROR on success, or some other win32 + error code on failure. + + + + + &reftitle.seealso; + + + win32_stop_service + + + + + + + + diff --git a/reference/win32service/functions/win32-stop-service.xml b/reference/win32service/functions/win32-stop-service.xml new file mode 100644 index 0000000000..e5d77bd25f --- /dev/null +++ b/reference/win32service/functions/win32-stop-service.xml @@ -0,0 +1,84 @@ + + + + + + win32_stop_service + Stops a service + + + &reftitle.description; + + longwin32_stop_service + stringservicename + stringmachine + + + + Stops a named service. Requires administrative privileges. + + + + + &reftitle.parameters; + + + + servicename + + + The short name of the service. + + + + + machine + + + Optional machine name. If omitted, the local machine is used. + + + + + + + + &reftitle.returnvalues; + + Returns WIN32_NO_ERROR on success, or a win32 error + code on failure. + + + + + &reftitle.seealso; + + + win32_start_service + + + + + + + + diff --git a/reference/win32service/reference.xml b/reference/win32service/reference.xml new file mode 100644 index 0000000000..e2f0248192 --- /dev/null +++ b/reference/win32service/reference.xml @@ -0,0 +1,129 @@ + + + + + + + win32service Functions + win32service + + +
+ &reftitle.intro; + + The win32service extension is a Windows specific extension that allows PHP + to communicate with the Service Control Manager to start, stop, register + and unregister extensions, and even allows your PHP scripts to run as a + service. + +
+
+ &reftitle.required; + + Windows NT, Windows 2000, Windows XP or Windows Server 2003. Any version + of windows derived from Windows NT should be compatible. + +
+
+ &reftitle.install; + + Installing from PECL + + + You can download php_win32service.dll from http://snaps.php.net/win32/. + Choose the PECL_X_X folder that matches you PHP version. + + + + + Copy the php_win32service.dll into you extension_dir. + + + + + Load the extension from your &php.ini; + + + + + + +
+ +
+ &reftitle.examples; + + Registering a PHP to run as a service + + 'dummyphp', # the name of your service + 'display' => 'sample dummy PHP service', # description + 'params' => 'c:\path\to\script.php run', # path to the script and parameters + )); +?> +]]> + + + + + Unregistering a service + + +]]> + + + + + Running as a service + + +]]> + + + +
+ + &reference.win32service.constants; +
+ &reference.win32service.functions; +
+ +