Source of: /manual/en/function.win32-start-service-ctrl-dispatcher.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.win32service.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.win32-start-service-ctrl-dispatcher.php',
1 => 'win32_start_service_ctrl_dispatcher',
),
'up' =>
array (
0 => 'ref.win32service.php',
1 => 'win32service Functions',
),
'prev' =>
array (
0 => 'function.win32-set-service-status.php',
1 => 'win32_set_service_status',
),
'next' =>
array (
0 => 'function.win32-start-service.php',
1 => 'win32_start_service',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.win32-start-service-ctrl-dispatcher" class="refentry">
<div class="refnamediv">
<h1 class="refname">win32_start_service_ctrl_dispatcher</h1>
<p class="verinfo">(PECL win32service SVN)</p><p class="refpurpose"><span class="refname">win32_start_service_ctrl_dispatcher</span> — <span class="dc-title">Registers the script with the SCM, so that it can act as the service with the given name</span></p>
</div>
<a name="function.win32-start-service-ctrl-dispatcher.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b>win32_start_service_ctrl_dispatcher</b></span>
( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$name</tt></span>
)</div>
<p class="para rdfs-comment">
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.
</p>
<p class="para">
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
<a href="function.win32-get-last-control-message.php" class="function">win32_get_last_control_message()</a> and handling the return
code appropriately.
</p>
</div>
<a name="function.win32-start-service-ctrl-dispatcher.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">name</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
The short-name of the service, as registered by
<a href="function.win32-create-service.php" class="function">win32_create_service()</a>.
</p>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.win32-start-service-ctrl-dispatcher.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
Returns <b><tt class="constant">TRUE</tt></b> on success, otherwise <b><tt class="constant">FALSE</tt></b> or a win32 error code.
</p>
</div>
<a name="function.win32-start-service-ctrl-dispatcher.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 A <b>win32_start_service_ctrl_dispatcher()</b> example</b></p>
<div class="example-contents para"><p>
Any text that describes the purpose of the example, or
what goes on in the example should go here (inside the
</p></div>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">win32_start_service_ctrl_dispatcher</span><span style="color: #007700">(</span><span style="color: #DD0000">'dummyphp'</span><span style="color: #007700">)) {<br /> die(</span><span style="color: #DD0000">"I'm probably not running under the service control manager"</span><span style="color: #007700">);<br />}<br /><br />while (</span><span style="color: #0000BB">WIN32_SERVICE_CONTROL_STOP </span><span style="color: #007700">!= </span><span style="color: #0000BB">win32_get_last_control_message</span><span style="color: #007700">()) {<br /> </span><span style="color: #FF8000"># do some work here, trying not to take more than around 30 seconds<br /> # before coming back into the loop again<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div><p>
</p>
</div>
<a name="function.win32-start-service-ctrl-dispatcher.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="function.win32-get-last-control-message.php" class="function" rel="rdfs-seeAlso">win32_get_last_control_message()</a> - Returns the last control message that was sent to this service</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>