<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.win32-start-service-ctrl-dispatcher.php',
    1 => 'win32_start_service_ctrl_dispatcher',
    2 => 'Enregistre un script avec SCM, alors il peut &ecirc;tre interpr&eacute;t&eacute; en tant que service avec le nom donn&eacute;',
  ),
  'up' => 
  array (
    0 => 'ref.win32service.php',
    1 => 'Fonctions win32service',
  ),
  'prev' => 
  array (
    0 => 'function.win32-start-service.php',
    1 => 'win32_start_service',
  ),
  'next' => 
  array (
    0 => 'function.win32-stop-service.php',
    1 => 'win32_stop_service',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/win32service/functions/win32-start-service-ctrl-dispatcher.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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 &gt;=0.1.0)</p><p class="refpurpose"><span class="refname">win32_start_service_ctrl_dispatcher</span> &mdash; <span class="dc-title">Enregistre un script avec SCM, alors il peut être interprété en tant que service avec le nom donné</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.win32-start-service-ctrl-dispatcher-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>win32_start_service_ctrl_dispatcher</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$gracefulMode</code><span class="initializer"> = true</span></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="para rdfs-comment">
   Lorsque exécuté via le Gestionnaire de Contrôle de Service, un processus de
   service est requis pour &quot;archiver&quot; avec lui pour établir un service de
   surveillance et de communication ergonomique. Cette fonction effectue un
   archivage en démarrant un thread pour gérer les communications de bas
   niveau avec le gestionnaire de contrôle de service.
  </p>
  <p class="para">
   Une fois démarré, le processus du service doit faire 2 choses. La première
   est d&#039;indiquer au Service Control Manager que le service est en cours
   d&#039;exécution. La seconde est d&#039;appeler la fonction
   <span class="function"><a href="function.win32-set-service-status.php" class="function">win32_set_service_status()</a></span> avec la constante
   <strong><code><a href="win32service.constants.php#constant.win32-service-running">WIN32_SERVICE_RUNNING</a></code></strong>. Si l&#039;on a besoin de
   lancer des processus longs avant que le service ne soit lancé, alors
   il est possible d&#039;utiliser la constante <strong><code><a href="win32service.constants.php#constant.win32-service-start-pending">WIN32_SERVICE_START_PENDING</a></code></strong>.
   La seconde est de continuer à vérifier en utilisant le Service Control Manager
   sachant qu&#039;il peut déterminer si le service se termine ou non. Ceci consiste
   à appeler, périodiquement, la fonction <span class="function"><a href="function.win32-get-last-control-message.php" class="function">win32_get_last_control_message()</a></span>
   et à traiter le code retourné.
  </p>
  
  <div class="caution"><strong class="caution">Attention</strong>
   <p class="para">
    Depuis la version 0.2.0, cette fonction fonctionne uniquement en ligne de 
    commande. Elle est désactivé dans les autres cas.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.win32-start-service-ctrl-dispatcher-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">name</code></dt>
     <dd>
      <p class="para">
       Le court nom du service, comme enregistré par
       <span class="function"><a href="function.win32-create-service.php" class="function">win32_create_service()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">gracefulMode</code></dt>
     <dd>
      <p class="para">
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> pour la sortie gracieuse. <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> pour la sortie avec erreur. Voir 
       <span class="function"><a href="function.win32-set-service-exit-mode.php" class="function">win32_set_service_exit_mode()</a></span> pour plus de détails.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.win32-start-service-ctrl-dispatcher-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Aucune valeur n&#039;est retournée.
  </p>
  <p class="para">
    Avant la version 1.0.0, retournait <strong><code><a href="win32service.constants.php#constant.win32-no-error">WIN32_NO_ERROR</a></code></strong> on success, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if there is a problem with the parameters or a <a href="win32service.constants.php#win32service.constants.errors" class="link">Win32 Error Code</a> on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.win32-start-service-ctrl-dispatcher-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Avant la version 1.0.0, si cette fonction est utilisé en dehors du SAPI <code class="literal">&quot;cli&quot;</code>, une 
   erreur <strong><code><a href="errorfunc.constants.php#constant.e-error">E_ERROR</a></code></strong> sera émise.
  </p>
  <p class="para">
   À partir de la version 1.0.0, lancera une 
   <span class="classname"><a href="class.win32serviceexception.php" class="classname">Win32ServiceException</a></span> si le SAPI n&#039;est pas 
   <code class="literal">&quot;cli&quot;</code>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.win32-start-service-ctrl-dispatcher-changelog">
  <h3 class="title">Historique</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL win32service 1.0.0</td>
       <td>
        Lance une <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> si un paramètre est invalide,
        avant <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> était retourné.
       </td>
      </tr>

      <tr>
       <td>PECL win32service 1.0.0</td>
       <td>
        Lance une <span class="classname"><a href="class.win32serviceexception.php" class="classname">Win32ServiceException</a></span> en cas d&#039;erreur,
        avant un
        <a href="win32service.constants.php#win32service.constants.errors" class="link">Code d&#039;erreur Win32</a>
        était retourné.
       </td>
      </tr>

      <tr>
       <td>PECL win32service 1.0.0</td>
       <td>
        Le type de retour est maintenant <span class="type"><span class="type"><a href="language.types.void.php" class="type void">void</a></span></span>, avant il était <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span>.
       </td>
      </tr>

      <tr>
       <td>PECL win32service 0.4.0</td>
       <td>
        Le paramètre <code class="parameter">gracefulMode</code> a été ajouté.
       </td>
      </tr>

      <tr>
       <td>PECL win32service 0.2.0</td>
       <td>
        Cette fonction fonctionne uniquement en ligne de
        commande.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.win32-start-service-ctrl-dispatcher-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>win32_start_service_ctrl_dispatcher()</strong></span></strong></p>
    <div class="example-contents"><p>
     Vérifie si le service fonctionne sous SCM.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?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">"Je ne fonctionne probablement pas sous le gestionnaire de contrôle de service"</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">win32_set_service_status</span><span style="color: #007700">(</span><span style="color: #0000BB">WIN32_SERVICE_START_PENDING</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Quelques processus longs à récupérer pendant que le service fonctionne.<br /><br /></span><span style="color: #0000BB">win32_set_service_status</span><span style="color: #007700">(</span><span style="color: #0000BB">WIN32_SERVICE_RUNNING</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"># effectuer votre travail ici.<br />  # essayez de ne pas prendre plus de 30 secondes avant de retourner au<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.win32-start-service-ctrl-dispatcher-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.win32-set-service-status.php" class="function" rel="rdfs-seeAlso">win32_set_service_status()</a> - Met &agrave; jour le statut d'un service</span></li>
    <li><span class="function"><a href="function.win32-get-last-control-message.php" class="function" rel="rdfs-seeAlso">win32_get_last_control_message()</a> - Retourne le dernier message de contr&ocirc;le qui a &eacute;t&eacute; envoy&eacute; &agrave; ce service</span></li>
    <li><span class="function"><a href="function.win32-set-service-exit-mode.php" class="function" rel="rdfs-seeAlso">win32_set_service_exit_mode()</a> - D&eacute;finir ou renvoyer le mode de sortie pour le service en cours d'ex&eacute;cution</span></li>
    <li><span class="function"><a href="function.win32-set-service-exit-code.php" class="function" rel="rdfs-seeAlso">win32_set_service_exit_code()</a> - D&eacute;finir ou renvoyer le code de sortie pour le service en cours d'ex&eacute;cution</span></li>
    <li>Les <a href="win32service.constants.php#win32service.constants.errors" class="link">codes erreur Win32</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>