}
LPQUERY_SERVICE_CONFIG
-GetServiceConfig(LPTSTR lpServiceName)
+GetServiceConfig(LPWSTR lpServiceName)
{
- LPQUERY_SERVICE_CONFIG lpServiceConfig = NULL;
+ LPQUERY_SERVICE_CONFIGW lpServiceConfig = NULL;
SC_HANDLE hSCManager;
SC_HANDLE hService;
DWORD dwBytesNeeded;
- hSCManager = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_ALL_ACCESS);
+ hSCManager = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_CONNECT);
if (hSCManager)
{
- hService = OpenService(hSCManager,
- lpServiceName,
- SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
+ hService = OpenServiceW(hSCManager,
+ lpServiceName,
+ SERVICE_QUERY_CONFIG);
if (hService)
{
- if (!QueryServiceConfig(hService,
- NULL,
- 0,
- &dwBytesNeeded))
+ if (!QueryServiceConfigW(hService,
+ NULL,
+ 0,
+ &dwBytesNeeded))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
dwBytesNeeded);
if (lpServiceConfig)
{
- if (!QueryServiceConfig(hService,
+ if (!QueryServiceConfigW(hService,
lpServiceConfig,
dwBytesNeeded,
&dwBytesNeeded))
BOOL
SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig,
- LPTSTR lpServiceName,
- LPTSTR lpPassword)
+ LPWSTR lpServiceName,
+ LPWSTR lpPassword)
{
SC_HANDLE hSCManager;
SC_HANDLE hSc;
SC_LOCK scLock;
BOOL bRet = FALSE;
- hSCManager = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_LOCK);
+ hSCManager = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_LOCK);
if (hSCManager)
{
scLock = LockServiceDatabase(hSCManager);
if (scLock)
{
- hSc = OpenService(hSCManager,
- lpServiceName,
- SERVICE_CHANGE_CONFIG);
+ hSc = OpenServiceW(hSCManager,
+ lpServiceName,
+ SERVICE_CHANGE_CONFIG);
if (hSc)
{
- if (ChangeServiceConfig(hSc,
- pServiceConfig->dwServiceType,
- pServiceConfig->dwStartType,
- pServiceConfig->dwErrorControl,
- pServiceConfig->lpBinaryPathName,
- pServiceConfig->lpLoadOrderGroup,
- pServiceConfig->dwTagId ? &pServiceConfig->dwTagId : NULL,
- pServiceConfig->lpDependencies,
- pServiceConfig->lpServiceStartName,
- lpPassword,
- pServiceConfig->lpDisplayName))
+ if (ChangeServiceConfigW(hSc,
+ pServiceConfig->dwServiceType,
+ pServiceConfig->dwStartType,
+ pServiceConfig->dwErrorControl,
+ pServiceConfig->lpBinaryPathName,
+ pServiceConfig->lpLoadOrderGroup,
+ pServiceConfig->dwTagId ? &pServiceConfig->dwTagId : NULL,
+ pServiceConfig->lpDependencies,
+ pServiceConfig->lpServiceStartName,
+ lpPassword,
+ pServiceConfig->lpDisplayName))
{
bRet = TRUE;
}
return bRet;
}
-LPTSTR
-GetServiceDescription(LPTSTR lpServiceName)
+LPWSTR
+GetServiceDescription(LPWSTR lpServiceName)
{
SC_HANDLE hSCManager = NULL;
SC_HANDLE hSc = NULL;
- SERVICE_DESCRIPTION *pServiceDescription = NULL;
- LPTSTR lpDescription = NULL;
+ SERVICE_DESCRIPTIONW *pServiceDescription = NULL;
+ LPWSTR lpDescription = NULL;
DWORD BytesNeeded = 0;
DWORD dwSize;
- hSCManager = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_ENUMERATE_SERVICE);
+ hSCManager = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_ENUMERATE_SERVICE);
if (hSCManager == NULL)
{
GetError();
return NULL;
}
- hSc = OpenService(hSCManager,
- lpServiceName,
- SERVICE_QUERY_CONFIG);
+ hSc = OpenServiceW(hSCManager,
+ lpServiceName,
+ SERVICE_QUERY_CONFIG);
if (hSc)
{
- if (!QueryServiceConfig2(hSc,
- SERVICE_CONFIG_DESCRIPTION,
- NULL,
- 0,
- &BytesNeeded))
+ if (!QueryServiceConfig2W(hSc,
+ SERVICE_CONFIG_DESCRIPTION,
+ NULL,
+ 0,
+ &BytesNeeded))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (pServiceDescription == NULL)
goto cleanup;
- if (QueryServiceConfig2(hSc,
- SERVICE_CONFIG_DESCRIPTION,
- (LPBYTE)pServiceDescription,
- BytesNeeded,
- &BytesNeeded))
+ if (QueryServiceConfig2W(hSc,
+ SERVICE_CONFIG_DESCRIPTION,
+ (LPBYTE)pServiceDescription,
+ BytesNeeded,
+ &BytesNeeded))
{
if (pServiceDescription->lpDescription)
{
- dwSize = _tcslen(pServiceDescription->lpDescription) + 1;
+ dwSize = wcslen(pServiceDescription->lpDescription) + 1;
lpDescription = HeapAlloc(ProcessHeap,
0,
- dwSize * sizeof(TCHAR));
+ dwSize * sizeof(WCHAR));
if (lpDescription)
{
- StringCchCopy(lpDescription,
- dwSize,
- pServiceDescription->lpDescription);
+ StringCchCopyW(lpDescription,
+ dwSize,
+ pServiceDescription->lpDescription);
}
}
}
}
BOOL
-SetServiceDescription(LPTSTR lpServiceName,
- LPTSTR lpDescription)
+SetServiceDescription(LPWSTR lpServiceName,
+ LPWSTR lpDescription)
{
SC_HANDLE hSCManager;
SC_HANDLE hSc;
SERVICE_DESCRIPTION ServiceDescription;
BOOL bRet = FALSE;
- hSCManager = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_LOCK);
+ hSCManager = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_LOCK);
if (hSCManager)
{
scLock = LockServiceDatabase(hSCManager);
if (scLock)
{
- hSc = OpenService(hSCManager,
- lpServiceName,
- SERVICE_CHANGE_CONFIG);
+ hSc = OpenServiceW(hSCManager,
+ lpServiceName,
+ SERVICE_CHANGE_CONFIG);
if (hSc)
{
ServiceDescription.lpDescription = lpDescription;
- if (ChangeServiceConfig2(hSc,
- SERVICE_CONFIG_DESCRIPTION,
- &ServiceDescription))
+ if (ChangeServiceConfig2W(hSc,
+ SERVICE_CONFIG_DESCRIPTION,
+ &ServiceDescription))
{
bRet = TRUE;
}
HeapFree(ProcessHeap,
0,
Info->pAllServices);
+ Info->pAllServices = NULL;
}
- ScHandle = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_ENUMERATE_SERVICE);
- if (ScHandle != INVALID_HANDLE_VALUE)
+ ScHandle = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_ENUMERATE_SERVICE);
+ if (ScHandle != NULL)
{
if (!EnumServicesStatusEx(ScHandle,
SC_ENUM_PROCESS_INFO,
if (ScHandle)
CloseServiceHandle(ScHandle);
- if (!bRet)
+ if (!bRet && Info->pAllServices)
{
HeapFree(ProcessHeap,
0,
SC_HANDLE hScm;
BOOL bRet = FALSE;
- hScm = OpenSCManager(NULL,
- NULL,
- SC_MANAGER_ENUMERATE_SERVICE);
- if (hScm != INVALID_HANDLE_VALUE)
+ hScm = OpenSCManagerW(NULL,
+ NULL,
+ SC_MANAGER_ENUMERATE_SERVICE);
+ if (hScm != NULL)
{
SC_HANDLE hService;
- hService = OpenService(hScm,
- pService->lpServiceName,
- SERVICE_QUERY_STATUS);
+ hService = OpenServiceW(hScm,
+ pService->lpServiceName,
+ SERVICE_QUERY_STATUS);
if (hService)
{
DWORD size;