Improve swedish translations and add new translations to swedish.
[reactos.git] / base / applications / mscutils / servman / dependencies_tv1.c
index c4753c1..27d376e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PROJECT:     ReactOS Services
  * LICENSE:     GPL - See COPYING in the top level directory
- * FILE:        base/applications/mscutils/servman/tv1_dependencies.c
+ * FILE:        base/applications/mscutils/servman/dependencies_tv1.c
  * PURPOSE:     Helper functions for service dependents
  * COPYRIGHT:   Copyright 2009 Ged Murphy <gedmurphy@reactos.org>
  *
@@ -9,21 +9,19 @@
 
 #include "precomp.h"
 
-
-LPTSTR
-TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
-                  SC_HANDLE hService)
+LPWSTR
+TV1_GetDependants(SC_HANDLE hService)
 {
     LPQUERY_SERVICE_CONFIG lpServiceConfig;
-    LPTSTR lpStr = NULL;
+    LPWSTR lpStr = NULL;
     DWORD bytesNeeded;
     DWORD bytes;
 
     /* Get the info for this service */
-    if (!QueryServiceConfig(hService,
-                            NULL,
-                            0,
-                            &bytesNeeded) &&
+    if (!QueryServiceConfigW(hService,
+                             NULL,
+                             0,
+                             &bytesNeeded) &&
         GetLastError() == ERROR_INSUFFICIENT_BUFFER)
     {
         lpServiceConfig = HeapAlloc(ProcessHeap,
@@ -31,10 +29,10 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
                                     bytesNeeded);
         if (lpServiceConfig)
         {
-            if (QueryServiceConfig(hService,
-                                   lpServiceConfig,
-                                   bytesNeeded,
-                                   &bytesNeeded))
+            if (QueryServiceConfigW(hService,
+                                    lpServiceConfig,
+                                    bytesNeeded,
+                                    &bytesNeeded))
             {
                 /* Does this service have any dependencies? */
                 if (lpServiceConfig->lpDependencies &&
@@ -44,7 +42,7 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
                     bytes = 0;
 
                     /* Work out how many bytes we need to hold the list */
-                    while (TRUE)
+                    for (;;)
                     {
                         bytes++;
 
@@ -58,7 +56,7 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
                     }
 
                     /* Allocate and copy the list */
-                    bytes *= sizeof(TCHAR);
+                    bytes *= sizeof(WCHAR);
                     lpStr = HeapAlloc(ProcessHeap,
                                       0,
                                       bytes);
@@ -81,30 +79,30 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
 }
 
 VOID
-TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
+TV1_AddDependantsToTree(PDEPENDDATA pDependData,
                         HTREEITEM hParent,
-                        LPTSTR lpServiceName)
+                        LPWSTR lpServiceName)
 {
     SC_HANDLE hSCManager;
     SC_HANDLE hService;
     LPQUERY_SERVICE_CONFIG lpServiceConfig;
-    LPTSTR lpDependants;
-    LPTSTR lpStr;
-    LPTSTR lpNoDepends;
+    LPWSTR lpDependants;
+    LPWSTR lpStr;
+    LPWSTR lpNoDepends;
     BOOL bHasChildren;
 
-    hSCManager = OpenSCManager(NULL,
-                               NULL,
-                               SC_MANAGER_ALL_ACCESS);
+    hSCManager = OpenSCManagerW(NULL,
+                                NULL,
+                                SC_MANAGER_ALL_ACCESS);
     if (hSCManager)
     {
-        hService = OpenService(hSCManager,
-                               lpServiceName,
-                               SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
+        hService = OpenServiceW(hSCManager,
+                                lpServiceName,
+                                SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
         if (hService)
         {
             /* Get a list of service dependents */
-            lpDependants = TV1_GetDependants(pDlgInfo, hService);
+            lpDependants = TV1_GetDependants(hService);
             if (lpDependants)
             {
                 lpStr = lpDependants;
@@ -128,7 +126,7 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
                         }
 
                         /* Add it */
-                        AddItemToTreeView(pDlgInfo->hDependsTreeView1,
+                        AddItemToTreeView(pDependData->hDependsTreeView1,
                                           hParent,
                                           lpServiceConfig->lpDisplayName,
                                           lpStr,
@@ -157,19 +155,17 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
                     /* Load the 'No dependencies' string */
                     AllocAndLoadString(&lpNoDepends, hInstance, IDS_NO_DEPENDS);
 
-                    AddItemToTreeView(pDlgInfo->hDependsTreeView1,
+                    AddItemToTreeView(pDependData->hDependsTreeView1,
                                       NULL,
                                       lpNoDepends,
                                       NULL,
                                       0,
                                       FALSE);
 
-                    HeapFree(ProcessHeap,
-                             0,
-                             lpNoDepends);
+                    LocalFree(lpNoDepends);
 
                     /* Disable the window */
-                    EnableWindow(pDlgInfo->hDependsTreeView1, FALSE);
+                    EnableWindow(pDependData->hDependsTreeView1, FALSE);
                 }
             }
 
@@ -180,27 +176,26 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
     }
 }
 
-
 BOOL
-TV1_Initialize(PSERVICEPROPSHEET pDlgInfo,
-               LPTSTR lpServiceName)
+TV1_Initialize(PDEPENDDATA pDependData,
+               LPWSTR lpServiceName)
 {
     BOOL bRet = FALSE;
 
-    /* Accociate the imagelist with TV1 */
-    pDlgInfo->hDependsTreeView1 = GetDlgItem(pDlgInfo->hDependsWnd, IDC_DEPEND_TREE1);
-    if (!pDlgInfo->hDependsTreeView1)
+    /* Associate the imagelist with TV1 */
+    pDependData->hDependsTreeView1 = GetDlgItem(pDependData->hDependsWnd, IDC_DEPEND_TREE1);
+    if (!pDependData->hDependsTreeView1)
     {
-        ImageList_Destroy(pDlgInfo->hDependsImageList);
-        pDlgInfo->hDependsImageList = NULL;
+        ImageList_Destroy(pDependData->hDependsImageList);
+        pDependData->hDependsImageList = NULL;
         return FALSE;
     }
-    (void)TreeView_SetImageList(pDlgInfo->hDependsTreeView1,
-                                pDlgInfo->hDependsImageList,
+    (void)TreeView_SetImageList(pDependData->hDependsTreeView1,
+                                pDependData->hDependsImageList,
                                 TVSIL_NORMAL);
 
     /* Set the first items in the control */
-    TV1_AddDependantsToTree(pDlgInfo, NULL, lpServiceName);
+    TV1_AddDependantsToTree(pDependData, NULL, lpServiceName);
 
     return bRet;
 }