Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 12290

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!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="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
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"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.win32-ps-stat-proc.html"
ACCESSKEY="P"
>上一页</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"
>下一页</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="AEN238657"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="win32service.intro"
>简介</A
></H1
><P
>&#13;    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"
>需求</A
></H1
><P
>&#13;    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"
>安装</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
>&#13;      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
>&#13;      Copy the php_win32service.dll into your <A
HREF="ini.core.html#ini.extension-dir"
>extension_dir</A
>.
     </P
></LI
><LI
CLASS="step"
><P
>&#13;      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"
>范例</A
></H1
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN238680"
></A
><P
><B
>例 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">&lt;?php<br />win32_create_service</font><font color="#007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'service' </font><font color="#007700">=&gt; </font><font color="#DD0000">'dummyphp'</font><font color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000"># the name of your service<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'display' </font><font color="#007700">=&gt; </font><font color="#DD0000">'sample dummy PHP service'</font><font color="#007700">, </font><font color="#FF8000"># description<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#DD0000">'params' </font><font color="#007700">=&gt; </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 />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#007700">));<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN238684"
></A
><P
><B
>例 2. Unregistering a service</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />win32_delete_service</font><font color="#007700">(</font><font color="#DD0000">'dummyphp'</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN238688"
></A
><P
><B
>例 3. Running as a service</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?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 />&nbsp;&nbsp;</font><font color="#0000BB">win32_start_service_ctrl_dispatcher</font><font color="#007700">(</font><font color="#DD0000">'dummyphp'</font><font color="#007700">);<br /><br />&nbsp;&nbsp;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 />&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FF8000"># do your work here.<br />&nbsp;&nbsp;&nbsp;&nbsp;# try not to take up more than 30 seconds before going around the loop<br />&nbsp;&nbsp;&nbsp;&nbsp;# again<br />&nbsp;&nbsp;</font><font color="#007700">}<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="win32service.constants"
>预定义常量</A
></H1
><P
>以下常量由本扩展模块定义,因此只有在本扩展模块被编译到
PHP 中,或者在运行时被动态加载后才有效。</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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </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
>&#13;
    </P
></DD
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.win32-create-service.html"
>win32_create_service</A
>&nbsp;--&nbsp;Creates a new service entry in the SCM database</DT
><DT
><A
HREF="function.win32-delete-service.html"
>win32_delete_service</A
>&nbsp;--&nbsp;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
>&nbsp;--&nbsp;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
>&nbsp;--&nbsp;Queries the status of a service</DT
><DT
><A
HREF="function.win32-set-service-status.html"
>win32_set_service_status</A
>&nbsp;--&nbsp;Update the service status</DT
><DT
><A
HREF="function.win32-start-service-ctrl-dispatcher.html"
>win32_start_service_ctrl_dispatcher</A
>&nbsp;--&nbsp;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
>&nbsp;--&nbsp;Starts a service</DT
><DT
><A
HREF="function.win32-stop-service.html"
>win32_stop_service</A
>&nbsp;--&nbsp;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"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.win32-create-service.html"
ACCESSKEY="N"
>下一页</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"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>win32_create_service</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>