win32service patch
| From: | Richard Quadling | Date: | Thu, 23 Jul 2009 14:37:49 +0000 |
| Subject: | win32service patch | ||
| Groups: | php.internals.win | ||
| Request: | Send a blank email to internals-win+get-550@lists.php.net to get a copy of this message | ||
Hi.
I've got my windows build working at last (thanks to Pierre - yep you
can blame him!).
The win32_service extension allows for a description to be supplied
when registering the service, but currently there is no support for
this in the code.
The supplied patch allows the description to be registered.
Help was gathered from 'ChangeServiceConfig2 Function' [1] and
'Changing a Service's Configuration' [2]
The patch also allows you to create services which are not run
automatically (WIN32_SERVICE_DEMAND_START for example).
Help was gathered from 'CreateService Function' [3].
Regards,
Richard Quadling.
[1] http://msdn.microsoft.com/en-us/library/ms681988(VS.85).aspx
[2] http://msdn.microsoft.com/en-us/library/ms682006(VS.85).aspx
[3] http://msdn.microsoft.com/en-us/library/ms682450(VS.85).aspx
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling
Index: pecl/win32service/trunk/win32service.c =================================================================== --- pecl/win32service/trunk/win32service.c (revision 284646) +++ pecl/win32service/trunk/win32service.c (working copy) @@ -174,6 +174,7 @@ char *desc; SC_HANDLE hsvc, hmgr; char *path_and_params; + SERVICE_DESCRIPTION srvc_desc; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|s!", &details, &machine, &machine_len)) { RETURN_FALSE; @@ -247,6 +248,8 @@ password); if (hsvc) { + srvc_desc.lpDescription = desc; + ChangeServiceConfig2(hsvc, SERVICE_CONFIG_DESCRIPTION, &srvc_desc); CloseServiceHandle(hsvc); RETVAL_TRUE; } else { @@ -442,6 +445,12 @@ #define MKCONST(x) REGISTER_LONG_CONSTANT("WIN32_" # x, x, CONST_CS|CONST_PERSISTENT) + MKCONST(SERVICE_BOOT_START); + MKCONST(SERVICE_SYSTEM_START); + MKCONST(SERVICE_AUTO_START); + MKCONST(SERVICE_DEMAND_START); + MKCONST(SERVICE_DISABLED); + MKCONST(SERVICE_CONTROL_CONTINUE); MKCONST(SERVICE_CONTROL_INTERROGATE); MKCONST(SERVICE_CONTROL_PAUSE);
Index: pecl/win32service/trunk/win32service.c =================================================================== --- pecl/win32service/trunk/win32service.c (revision 284646) +++ pecl/win32service/trunk/win32service.c (working copy) @@ -174,6 +174,7 @@ char *desc; SC_HANDLE hsvc, hmgr; char *path_and_params; + SERVICE_DESCRIPTION srvc_desc; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|s!", &details, &machine, &machine_len)) { RETURN_FALSE; @@ -247,6 +248,8 @@ password); if (hsvc) { + srvc_desc.lpDescription = desc; + ChangeServiceConfig2(hsvc, SERVICE_CONFIG_DESCRIPTION, &srvc_desc); CloseServiceHandle(hsvc); RETVAL_TRUE; } else { @@ -442,6 +445,12 @@ #define MKCONST(x) REGISTER_LONG_CONSTANT("WIN32_" # x, x, CONST_CS|CONST_PERSISTENT) + MKCONST(SERVICE_BOOT_START); + MKCONST(SERVICE_SYSTEM_START); + MKCONST(SERVICE_AUTO_START); + MKCONST(SERVICE_DEMAND_START); + MKCONST(SERVICE_DISABLED); + MKCONST(SERVICE_CONTROL_CONTINUE); MKCONST(SERVICE_CONTROL_INTERROGATE); MKCONST(SERVICE_CONTROL_PAUSE);