PHP Velho Oeste 2024

win32_get_last_control_message

(PECL win32service >=0.1.0)

win32_get_last_control_messageサービスに送信された直近の制御メッセージを返す

説明

win32_get_last_control_message(): int

サービスプロセスに送信された、直近の制御コードを返します。 サービスの実行中は、サービスを停止させる必要がないかを調べるために 定期的にこれをチェックすべきです。

警告

0.2.0 以降では、この関数は "cli" SAPI でのみ動作します。 他の SAPI では、この関数は無効になっています。

パラメータ

この関数にはパラメータはありません。

戻り値

制御コード定数を返します。以下の Win32Service サービス制御メッセージ定数 のひとつです。 WIN32_SERVICE_CONTROL_CONTINUE, WIN32_SERVICE_CONTROL_DEVICEEVENT, WIN32_SERVICE_CONTROL_HARDWAREPROFILECHANGE, WIN32_SERVICE_CONTROL_INTERROGATE, WIN32_SERVICE_CONTROL_NETBINDADD, WIN32_SERVICE_CONTROL_NETBINDDISABLE, WIN32_SERVICE_CONTROL_NETBINDENABLE, WIN32_SERVICE_CONTROL_NETBINDREMOVE, WIN32_SERVICE_CONTROL_PARAMCHANGE, WIN32_SERVICE_CONTROL_PAUSE, WIN32_SERVICE_CONTROL_POWEREVENT, WIN32_SERVICE_CONTROL_PRESHUTDOWN, WIN32_SERVICE_CONTROL_SESSIONCHANGE, WIN32_SERVICE_CONTROL_SHUTDOWN, WIN32_SERVICE_CONTROL_STOP

値が 128 から 255 の場合、制御コードはカスタムの値です。

エラー / 例外

バージョン 1.0.0 より前のバージョンでは、SAPI が "cli" でない場合、 この関数は E_ERROR レベルのエラーを発生させていました。

バージョン 1.0.0 移行は、 SAPI が "cli" でない場合、 Win32ServiceException がスローされます。

変更履歴

バージョン 説明
PECL win32service 1.0.0 引数に不正な値があった場合、 ValueError をスローするようになりました。 これより前のバージョンでは、false を返していました。
PECL win32service 1.0.0 エラー時に Win32ServiceException をスローするようになりました。 これより前のバージョンでは、 Win32 エラーコード を返していました。
PECL win32service 0.2.0 この関数は "cli" SAPI でのみ動作するようになりました。

参考

add a note add a note

User Contributed Notes 1 note

up
0
kermodebea at kermodebear dot Oh Are Gee
18 years ago
The definitions of some of these control codes can be found here (URL broken due to comment system, sorry about that!): http://msdn.microsoft.com/library
/default.asp?url=/library/en-us/dllproc/base/handler.asp

However, for your convenience (and mine):
SERVICE_CONTROL_STOP, 0x00000001
Notifies a service that it should stop.

If a service accepts this control code, it must stop upon receipt. After the SCM sends this control code, it does not send other control codes.

Windows XP/2000:  If the service returns NO_ERROR and continues to run, it continues to receive control codes. This behavior changed starting with Windows Server 2003 and Windows XP SP2.

SERVICE_CONTROL_PAUSE, 0x00000002
Notifies a service that it should pause.
(Although I guess that there is no requirement that you must.)

SERVICE_CONTROL_CONTINUE, 0x00000003
Notifies a paused service that it should resume.

SERVICE_CONTROL_INTERROGATE, 0x00000004
Notifies a service that it should report its current status information to the service control manager.
(I'm guessing that a call to win32_set_service_status() would satisfy interrogation?)

SERVICE_CONTROL_SHUTDOWN, 0x00000005
Notifies a service that the system is shutting down so the service can perform cleanup tasks.
To Top