[pywin32-checkins] pywin32/win32/src win32service.i,1.5,1.6
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-01-08 00:15:21
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24910/win32/src Modified Files: win32service.i Log Message: Add GetServiceDisplayName and GetServiceKeyName, and some autoduck improvements Index: win32service.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32service.i 6 Sep 2004 19:25:08 -0000 1.5 --- win32service.i 8 Jan 2005 00:15:07 -0000 1.6 *************** *** 11,14 **** --- 11,16 ---- #include "PyWinObjects.h" static BOOL (WINAPI *fpQueryServiceStatusEx)(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD) = NULL; + // according to msdn, 256 is limit for service names and service display names + #define MAX_SERVICE_NAME_LEN 256 %} *************** *** 835,838 **** --- 837,842 ---- // These 3 function contributed by Curt Hagenlocher + // @pyswig (tuple,...)|EnumServicesStatus|Returns a tuple of status info for each service that meets specified criteria + // @comm Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumServicesStatus) MyEnumServicesStatus; *************** *** 840,844 **** static PyObject *MyEnumServicesStatus(PyObject *self, PyObject *args) { ! SC_HANDLE hscm; DWORD serviceType = SERVICE_WIN32; DWORD serviceState = SERVICE_STATE_ALL; --- 844,851 ---- static PyObject *MyEnumServicesStatus(PyObject *self, PyObject *args) { ! // @pyparm int|hSCManager||Handle to service control manager as returned by <om win32service.OpenSCManager> ! // @pyparm int|ServiceType|SERVICE_WIN32|Types of services to enumerate (SERVICE_DRIVER and/or SERVICE_WIN32) ! // @pyparm int|ServiceState|SERVICE_STATE_ALL|Limits to services in specified state ! SC_HANDLE hscm; DWORD serviceType = SERVICE_WIN32; DWORD serviceState = SERVICE_STATE_ALL; *************** *** 899,906 **** --- 906,917 ---- %} + // @pyswig (tuple,...)|EnumDependentServices|Lists services that depend on a service + // @comm Returns a sequence of tuples representing ENUM_SERVICE_STATUS structs: (ServiceName, DisplayName, <o SERVICE_STATUS>) %native (EnumDependentServices) MyEnumDependentServices; %{ static PyObject *MyEnumDependentServices(PyObject *self, PyObject *args) { + // @pyparm int|hService||Handle to service for which to list dependent services (as returned by <om win32service.OpenService>) + // @pyparm int|ServiceState|SERVICE_STATE_ALL|Limits to services in specified state - One of SERVICE_STATE_ALL, SERVICE_ACTIVE, SERVICE_INACTIVE SC_HANDLE hsc; DWORD serviceState = SERVICE_STATE_ALL; *************** *** 961,964 **** --- 972,978 ---- %} + // @pyswig tuple|QueryServiceConfig|Retrieves configuration parameters for a service + // @comm Returns a tuple representing a QUERY_SERVICE_CONFIG struct: + // (ServiceType, StartType, ErrorControl, BinaryPathName, LoadOrderGroup, TagId, Dependencies, ServiceStartName, DisplayName) %native (QueryServiceConfig) MyQueryServiceConfig; *************** *** 966,969 **** --- 980,984 ---- static PyObject *MyQueryServiceConfig(PyObject *self, PyObject *args) { + // @pyparm int|hService||Service handle as returned by <om win32service.OpenService> SC_HANDLE hsc; if (!PyArg_ParseTuple(args, "l:QueryServiceConfig", &hsc)) *************** *** 1191,1198 **** %} ! // @pyswig <o SERVICE_STATUS>|SetServiceStatus|Sets a service status BOOLAPI SetServiceStatus( SERVICE_STATUS_HANDLE hSCManager, // @pyparm int|scHandle||Handle to set ! SERVICE_STATUS *inServiceStatus); // @pyparm object|serviceStatus||The new status // @pyswig <o SERVICE_STATUS>|ControlService|Sends a control message to a service. --- 1206,1263 ---- %} ! // @pyswig <o PyUNICODE>|GetServiceKeyName|Translates a service display name into its registry key name ! %native (GetServiceKeyName) MyGetServiceKeyName; ! %{ ! PyObject *MyGetServiceKeyName(PyObject *self, PyObject *args) ! { ! // @pyparm int|hSCManager||Handle to service control manager as returned by <om win32service.OpenSCManager> ! // @pyparm <o PyUNICODE>|DisplayName||Display name of a service ! SC_HANDLE h; ! WCHAR *displayname; ! WCHAR keyname[MAX_SERVICE_NAME_LEN]; ! DWORD bufsize=MAX_SERVICE_NAME_LEN; ! PyObject *obdisplayname, *ret=NULL; ! if (!PyArg_ParseTuple(args,"lO", &h, &obdisplayname)) ! return NULL; ! if (!PyWinObject_AsWCHAR(obdisplayname, &displayname, FALSE)) ! return NULL; ! if (!GetServiceKeyNameW(h, displayname, keyname, &bufsize)) ! PyWin_SetAPIError("GetServiceKeyName"); ! else ! ret=PyWinObject_FromWCHAR(keyname, bufsize); ! PyWinObject_FreeWCHAR(displayname); ! return ret; ! } ! %} ! ! // @pyswig <o PyUNICODE>|GetServiceDisplayName|Translates an internal service name into its display name ! %native (GetServiceDisplayName) MyGetServiceDisplayName; ! %{ ! PyObject *MyGetServiceDisplayName(PyObject *self, PyObject *args) ! { ! // @pyparm int|hSCManager||Handle to service control manager as returned by <om win32service.OpenSCManager> ! // @pyparm <o PyUNICODE>|ServiceName||Name of service ! SC_HANDLE h; ! WCHAR *keyname; ! WCHAR displayname[MAX_SERVICE_NAME_LEN]; ! DWORD bufsize=MAX_SERVICE_NAME_LEN; ! PyObject *obkeyname, *ret=NULL; ! if (!PyArg_ParseTuple(args,"lO", &h, &obkeyname)) ! return NULL; ! if (!PyWinObject_AsWCHAR(obkeyname, &keyname, FALSE)) ! return NULL; ! if (!GetServiceDisplayNameW(h, keyname, displayname, &bufsize)) ! PyWin_SetAPIError("GetServiceDisplayName"); ! else ! ret=PyWinObject_FromWCHAR(displayname); ! PyWinObject_FreeWCHAR(keyname); ! return ret; ! } ! %} ! ! // @pyswig |SetServiceStatus|Sets a service status BOOLAPI SetServiceStatus( SERVICE_STATUS_HANDLE hSCManager, // @pyparm int|scHandle||Handle to set ! SERVICE_STATUS *inServiceStatus); // @pyparm <o SERVICE_STATUS>|serviceStatus||The new status // @pyswig <o SERVICE_STATUS>|ControlService|Sends a control message to a service. |