<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >win32service Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="win32_ps_stat_proc" HREF="function.win32-ps-stat-proc.html"><LINK REL="NEXT" TITLE="win32_create_service" HREF="function.win32-create-service.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.win32-ps-stat-proc.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.win32-create-service.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.win32service" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CLXXVI. win32service Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN231975" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="win32service.intro" >Introdução</A ></H1 ><P > The win32service extension is a Windows specific extension that allows PHP to communicate with the Service Control Manager to start, stop, register and unregister services, and even allows your PHP scripts to run as a service. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="win32service.requirements" >Dependências</A ></H1 ><P > Windows NT, Windows 2000, Windows XP or Windows Server 2003. Any version of Windows derived from Windows NT should be compatible. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="win32service.install" >Instalação</A ></H1 ><DIV CLASS="procedure" ><P ><B ><A NAME="win32service.install-from-pecl" ></A >Installing from PECL</B ></P ><OL TYPE="1" ><LI CLASS="step" ><P > You can download php_win32service.dll from http://snaps.php.net/win32/. Choose the PECL_X_X folder that matches you PHP version. </P ></LI ><LI CLASS="step" ><P > Copy the php_win32service.dll into your <A HREF="ini.core.html#ini.extension-dir" >extension_dir</A >. </P ></LI ><LI CLASS="step" ><P > Load the extension from your <TT CLASS="filename" >php.ini</TT > <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >extension=php_win32service.dll</PRE ></TD ></TR ></TABLE > </P ></LI ></OL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="win32service.examples" >Exemplos</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN231998" ></A ><P ><B >Exemplo 1. Registering a PHP script to run as a service</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />win32_create_service</font><font color="#007700">(array(<br /> </font><font color="#DD0000">'service' </font><font color="#007700">=> </font><font color="#DD0000">'dummyphp'</font><font color="#007700">, </font><font color="#FF8000"># the name of your service<br /> </font><font color="#DD0000">'display' </font><font color="#007700">=> </font><font color="#DD0000">'sample dummy PHP service'</font><font color="#007700">, </font><font color="#FF8000"># description<br /> </font><font color="#DD0000">'params' </font><font color="#007700">=> </font><font color="#DD0000">'c:\path\to\script.php run'</font><font color="#007700">, </font><font color="#FF8000"># path to the script and parameters<br /> </font><font color="#007700">));<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN232002" ></A ><P ><B >Exemplo 2. Unregistering a service</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />win32_delete_service</font><font color="#007700">(</font><font color="#DD0000">'dummyphp'</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN232006" ></A ><P ><B >Exemplo 3. Running as a service</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#007700">if (</font><font color="#0000BB">$argv</font><font color="#007700">[</font><font color="#0000BB">1</font><font color="#007700">] == </font><font color="#DD0000">'run'</font><font color="#007700">) {<br /> </font><font color="#0000BB">win32_start_service_ctrl_dispatcher</font><font color="#007700">(</font><font color="#DD0000">'dummyphp'</font><font color="#007700">);<br /><br /> while (</font><font color="#0000BB">WIN32_SERVICE_CONTROL_STOP </font><font color="#007700">!= </font><font color="#0000BB">win32_get_last_control_message</font><font color="#007700">()) {<br /> </font><font color="#FF8000"># do your work here.<br /> # try not to take up more than 30 seconds before going around the loop<br /> # again<br /> </font><font color="#007700">}<br />}<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="win32service.constants" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_CONTINUE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_INTERROGATE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_PAUSE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_STOP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_HARDWAREPROFILECHANGE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_POWEREVENT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTROL_SESSIONCHANGE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_ERROR_CALL_NOT_IMPLEMENTED</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_NO_ERROR</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_RUNNING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_STOPPED</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_STOP_PENDING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_WIN32_OWN_PROCESS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_INTERACTIVE_PROCESS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_STOPPED</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_START_PENDING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_STOP_PENDING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_RUNNING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_CONTINUE_PENDING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_PAUSE_PENDING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_PAUSED</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_NETBINDCHANGE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_PARAMCHANGE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_PAUSE_CONTINUE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_SHUTDOWN</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_STOP</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_HARDWAREPROFILECHANGE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_POWEREVENT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_ACCEPT_SESSIONCHANGE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_FILE_SYSTEM_DRIVER</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_KERNEL_DRIVER</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_WIN32_SHARE_PROCESS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >WIN32_SERVICE_RUNS_IN_SYSTEM_PROCESS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.win32-create-service.html" >win32_create_service</A > -- Creates a new service entry in the SCM database</DT ><DT ><A HREF="function.win32-delete-service.html" >win32_delete_service</A > -- Deletes a service entry from the SCM database</DT ><DT ><A HREF="function.win32-get-last-control-message.html" >win32_get_last_control_message</A > -- Returns the last control message that was sent to this service</DT ><DT ><A HREF="function.win32-query-service-status.html" >win32_query_service_status</A > -- Queries the status of a service</DT ><DT ><A HREF="function.win32-set-service-status.html" >win32_set_service_status</A > -- Update the service status</DT ><DT ><A HREF="function.win32-start-service-ctrl-dispatcher.html" >win32_start_service_ctrl_dispatcher</A > -- Registers the script with the SCM, so that it can act as the service with the given name</DT ><DT ><A HREF="function.win32-start-service.html" >win32_start_service</A > -- Starts a service</DT ><DT ><A HREF="function.win32-stop-service.html" >win32_stop_service</A > -- Stops a service</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.win32-ps-stat-proc.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.win32-create-service.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >win32_ps_stat_proc</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >win32_create_service</TD ></TR ></TABLE ></DIV ></BODY ></HTML >