Querying a Service's Configuration
来源:互联网 发布:金山软件 编辑:程序博客网 时间:2024/05/22 00:33
Querying a Service's Configuration
In the following example, a service configuration program uses the OpenService function to get a handle with SERVICE_QUERY_CONFIG access to an installed service object. Then the program uses the service object handle in the QueryServiceConfig function to retrieve the current configuration of the service.
#include <windows.h>#include <stdio.h>BOOL GetSampleServiceConfig() { LPQUERY_SERVICE_CONFIG lpqscBuf; LPSERVICE_DESCRIPTION lpqscBuf2; DWORD dwBytesNeeded; BOOL bSuccess=TRUE; // Open a handle to the service. schService = OpenService( schSCManager, // SCManager database TEXT("Sample_Srv"), // name of service SERVICE_QUERY_CONFIG); // need QUERY access if (schService == NULL) { printf("OpenService failed (%d)", GetLastError()); return FALSE; } // Allocate a buffer for the configuration information. lpqscBuf = (LPQUERY_SERVICE_CONFIG) LocalAlloc( LPTR, 4096); if (lpqscBuf == NULL) { return FALSE; } lpqscBuf2 = (LPSERVICE_DESCRIPTION) LocalAlloc( LPTR, 4096); if (lpqscBuf2 == NULL) { return FALSE; } // Get the configuration information. if (! QueryServiceConfig( schService, lpqscBuf, 4096, &dwBytesNeeded) ) { printf("QueryServiceConfig failed (%d)", GetLastError()); bSuccess = FALSE; } if (! QueryServiceConfig2( schService, SERVICE_CONFIG_DESCRIPTION, lpqscBuf2, 4096, &dwBytesNeeded) ) { printf("QueryServiceConfig2 failed (%d)", GetLastError()); bSuccess = FALSE; } // Print the configuration information. printf("/nSample_Srv configuration: /n"); printf(" Type: 0x%x/n", lpqscBuf->dwServiceType); printf(" Start Type: 0x%x/n", lpqscBuf->dwStartType); printf(" Error Control: 0x%x/n", lpqscBuf->dwErrorControl); printf(" Binary path: %s/n", lpqscBuf->lpBinaryPathName); if (lpqscBuf->lpLoadOrderGroup != NULL) printf(" Load order group: %s/n", lpqscBuf->lpLoadOrderGroup); if (lpqscBuf->dwTagId != 0) printf(" Tag ID: %d/n", lpqscBuf->dwTagId); if (lpqscBuf->lpDependencies != NULL) printf(" Dependencies: %s/n", lpqscBuf->lpDependencies); if (lpqscBuf->lpServiceStartName != NULL) printf(" Start Name: %s/n", lpqscBuf->lpServiceStartName); if (lpqscBuf2->lpDescription != NULL) printf(" Description: %s/n", lpqscBuf2->lpDescription); LocalFree(lpqscBuf); LocalFree(lpqscBuf2); return bSuccess;}
- Querying a Service's Configuration
- Changing a Service Configuration
- PHP - Querying a MySQL Database
- Writing a Service Program's main Function
- Querying a MySQL database with LoadRunner
- Querying a DHCP server in C#
- Web service certificates configuration
- Service Support- Configuration Management
- Configuration Service Provider
- WCF Service Configuration Editor
- Spring's transaction configuration
- Consider defining a bean of type 'com.taikang.service.ChongyGameInfoService' in your configuration.
- Consider defining a bean of type 'com.xxx.service.impl.xxxImpl' in your configuration
- Beginning configuration step: Starting Server Starting MySQL as a service 解决方案
- 2013长沙现场赛A - Alice's Print Service
- emulator: ERROR:This AVD's configuration is missing a kernel file!!
- emulator:ERROR:This AVD's configuration is missing a kernel file! 解决方法
- emulator:ERROR:This AVD's configuration is missing a kernel file!!
- Opening an SCManager Database
- Installing a Service
- Deleting a Service
- Changing a Service Configuration
- 给中国学生的第三封信:成功、自信、快乐(李开复)--转载
- Querying a Service's Configuration
- Starting a Service
- Stopping a Service
- Sending Control Requests to a Service
- Modifying the DACL for a Service
- 给中国学生的第二封信(李开复)--转载
- ChangeServiceConfig
- ChangeServiceConfig2
- CloseServiceHandle