* LICENSE: GPL - See COPYING in the top level directory\r
* FILE: subsys/system/servman/query.c\r
* PURPOSE: Query service information\r
- * COPYRIGHT: Copyright 2005 Ged Murphy <gedmurphy@gmail.com>\r
+ * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy <gedmurphy@gmail.com>\r
*\r
*/\r
\r
HeapFree(GetProcessHeap(), 0, pServiceStatus);\r
}\r
\r
+\r
/* Retrives the service description from the registry */\r
BOOL GetDescription(HKEY hKey, LPTSTR *retDescription)\r
{\r
}\r
\r
\r
+/* get vendor of service binary */\r
BOOL GetExecutablePath(LPTSTR *ExePath)\r
{\r
+ LPQUERY_SERVICE_CONFIG pServiceConfig = NULL;\r
+ SC_HANDLE hService = NULL;\r
+ LVITEM item;\r
+ WORD wCodePage, wLangID;\r
+ DWORD BytesNeeded = 0, dwHandle, dwLen;\r
+ TCHAR FileName[MAX_PATH];\r
+ LPTSTR lpData;\r
+ LPTSTR lpBuffer;\r
+ TCHAR szStrFileInfo[80];\r
+ LPVOID pvData;\r
+ UINT BufLen;\r
+\r
+\r
+ if (!QueryServiceConfig(hService, pServiceConfig, 0, &BytesNeeded))\r
+ {\r
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)\r
+ {\r
+ pServiceConfig = (LPQUERY_SERVICE_CONFIG)\r
+ HeapAlloc(GetProcessHeap(), 0, BytesNeeded);\r
+ if (pServiceConfig == NULL)\r
+ return FALSE;\r
+\r
+ if (!QueryServiceConfig(hService,\r
+ pServiceConfig,\r
+ BytesNeeded,\r
+ &BytesNeeded))\r
+ {\r
+ HeapFree(GetProcessHeap(), 0, pServiceConfig);\r
+ return FALSE;\r
+ }\r
+ }\r
+ else /* exit on failure */\r
+ {\r
+ return FALSE;\r
+ }\r
+ }\r
+\r
+ memset(&FileName, 0, MAX_PATH);\r
+ if (_tcscspn(pServiceConfig->lpBinaryPathName, _T("\"")))\r
+ {\r
+ _tcsncpy(FileName, pServiceConfig->lpBinaryPathName,\r
+ _tcscspn(pServiceConfig->lpBinaryPathName, _T(" ")) );\r
+ }\r
+ else\r
+ {\r
+ _tcscpy(FileName, pServiceConfig->lpBinaryPathName);\r
+ }\r
\r
- return FALSE;\r
+ HeapFree(GetProcessHeap(), 0, pServiceConfig);\r
+ pServiceConfig = NULL;\r
+\r
+ dwLen = GetFileVersionInfoSize(FileName, &dwHandle);\r
+ if (dwLen)\r
+ {\r
+ lpData = (TCHAR*) HeapAlloc(GetProcessHeap(), 0, dwLen);\r
+ if (lpData == NULL)\r
+ return FALSE;\r
+\r
+ if (!GetFileVersionInfo (FileName, dwHandle, dwLen, lpData)) {\r
+ HeapFree(GetProcessHeap(), 0, lpData);\r
+ return FALSE;\r
+ }\r
+\r
+ if (VerQueryValue(lpData, _T("\\VarFileInfo\\Translation"), &pvData, (PUINT) &BufLen))\r
+ {\r
+ wCodePage = LOWORD(*(DWORD*) pvData);\r
+ wLangID = HIWORD(*(DWORD*) pvData);\r
+ wsprintf(szStrFileInfo, _T("StringFileInfo\\%04X%04X\\CompanyName"), wCodePage, wLangID);\r
+ }\r
+\r
+ if (VerQueryValue (lpData, szStrFileInfo, (LPVOID) &lpBuffer, (PUINT) &BufLen)) {\r
+ item.pszText = lpBuffer;\r
+ item.iSubItem = 2;\r
+ SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+ }\r
+ HeapFree(GetProcessHeap(), 0, lpData);\r
+ }\r
+ /*else\r
+ {\r
+ LoadString(hInstance, IDS_SERVICES_UNKNOWN, szStatus, 128);\r
+ item.pszText = szStatus;\r
+ item.iSubItem = 2;\r
+ SendMessage(hListView, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);\r
+ }*/\r
+\r
+ CloseServiceHandle(hService);\r
+\r
+ return TRUE;\r
}\r
\r
\r
+\r
+\r
BOOL\r
RefreshServiceList(VOID)\r
{\r
CloseServiceHandle(hService);\r
}\r
*/\r
+\r