[DEVMGR]
authorGed Murphy <gedmurphy@reactos.org>
Tue, 7 Jul 2015 11:05:25 +0000 (11:05 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Tue, 7 Jul 2015 11:05:25 +0000 (11:05 +0000)
- last few fixes to the device manager code to get it building with rosbe (msvc)
- Next steps are to merge it with the existing devmgr code (mostly done in my WC) and get it running via mmc.exe & devmgmt.msc

svn path=/trunk/; revision=68367

reactos/dll/win32/devmgr/devmgmt/ClassNode.cpp
reactos/dll/win32/devmgr/devmgmt/DeviceNode.cpp
reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp
reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
reactos/dll/win32/devmgr/devmgmt/MainWindow.h
reactos/dll/win32/devmgr/devmgmt/Node.cpp
reactos/dll/win32/devmgr/devmgmt/Node.h
reactos/dll/win32/devmgr/devmgmt/RootNode.cpp
reactos/dll/win32/devmgr/devmgmt/stdafx.h

index b2c1471..249925c 100644 (file)
@@ -120,7 +120,7 @@ CClassNode::ConvertResourceDescriptorToString(
     if (ptr)
     {
         // This must be an inf based descriptor, the desc is after the semi colon
-        wcscpy_s(ResourceDescriptor, ResourceDescriptorSize, ++ptr);
+        StringCbCopyW(ResourceDescriptor, ResourceDescriptorSize, ++ptr);
         dwError = ERROR_SUCCESS;
     }
     else
@@ -154,7 +154,7 @@ CClassNode::ConvertResourceDescriptorToString(
         // Load the string from the dll
         if (LoadStringW(hModule, ResourceId, ResString, 256))
         {
-            wcscpy_s(ResourceDescriptor, ResourceDescriptorSize, ResString);
+            StringCbCopyW(ResourceDescriptor, ResourceDescriptorSize, ResString);
             dwError = ERROR_SUCCESS;
         }
         else
index 42e8090..b15ce5a 100644 (file)
@@ -274,7 +274,6 @@ CDeviceNode::EnableDevice(
     _Out_ bool &NeedsReboot
     )
 {
-    bool Ret = false;
     bool Canceled = false;
 
     SetFlags(DI_NODI_DEFAULTACTION, 0);
@@ -376,6 +375,8 @@ CDeviceNode::UninstallDevice()
                                   NULL,
                                   0);
 
+    return true;
+
 }
 
 /* PRIVATE METHODS ******************************************************/
@@ -424,9 +425,9 @@ CDeviceNode::SetFlags(
     {
         DevInstallParams.Flags |= Flags;
         DevInstallParams.FlagsEx |= FlagsEx;
-        return SetupDiSetDeviceInstallParamsW(m_hDevInfo,
-                                              &m_DevinfoData,
-                                              &DevInstallParams);
+        return (SetupDiSetDeviceInstallParamsW(m_hDevInfo,
+                                               &m_DevinfoData,
+                                               &DevInstallParams) != 0);
     }
     return false;
 }
@@ -445,9 +446,9 @@ CDeviceNode::RemoveFlags(
     {
         DevInstallParams.Flags &= ~Flags;
         DevInstallParams.FlagsEx &= ~FlagsEx;
-        return SetupDiSetDeviceInstallParamsW(m_hDevInfo,
-                                              &m_DevinfoData,
-                                              &DevInstallParams);
+        return (SetupDiSetDeviceInstallParamsW(m_hDevInfo,
+                                               &m_DevinfoData,
+                                               &DevInstallParams) != 0);
     }
     return false;
 }
index d314f96..ba6cae9 100644 (file)
@@ -19,6 +19,7 @@
 #define CLASS_DESC_LEN      256
 #define ROOT_NAME_SIZE      MAX_COMPUTERNAME_LENGTH + 1
 
+extern "C" {
 INT_PTR
 WINAPI
 DevicePropertiesExW(
@@ -28,7 +29,7 @@ DevicePropertiesExW(
     IN DWORD dwFlags OPTIONAL,
     IN BOOL bShowDevMgr
 );
-
+}
 typedef INT_PTR(WINAPI *pDevicePropertiesExW)(HWND,LPCWSTR,LPCWSTR,DWORD,BOOL);
 
 struct RefreshThreadData
@@ -214,7 +215,7 @@ CDeviceView::Refresh(
         // Node gets deleted on refresh so we copy it to another block
         size_t Length = wcslen(DeviceId) + 1;
         ThreadData->DeviceId = new WCHAR[Length];
-        wcscpy_s(ThreadData->DeviceId, Length, DeviceId);
+        StringCbCopyW(ThreadData->DeviceId, Length, DeviceId);
     }
 
 
@@ -458,7 +459,6 @@ CDeviceView::ListDevicesByType()
     HTREEITEM hTreeItem = NULL;
     GUID ClassGuid;
     INT ClassIndex;
-    LPTSTR DeviceId = NULL;
     BOOL bClassSuccess, bSuccess;
 
     // Start by adding the root node to the tree
@@ -475,7 +475,7 @@ CDeviceView::ListDevicesByType()
             bool bClassUnknown = false;
             bool AddedParent = false;
             INT DeviceIndex = 0;
-            BOOL MoreItems;
+            bool MoreItems = false;
 
             // Get the cached class node
             ClassNode = GetClassNode(&ClassGuid);
@@ -500,11 +500,11 @@ CDeviceView::ListDevicesByType()
                                                  DeviceIndex,
                                                  &DeviceInfoData);
                 if (bSuccess == FALSE && GetLastError() == ERROR_NO_MORE_ITEMS)
-                    MoreItems = FALSE;
+                    MoreItems = false;
 
                 if (bSuccess)
                 {
-                    MoreItems = TRUE;
+                    MoreItems = true;
 
                     // The unknown class handle contains all devices on the system,
                     // and we're just looking for the ones with a null GUID
index ef55d10..6f43b4f 100644 (file)
@@ -208,7 +208,7 @@ CMainWindow::UpdateStatusBar(
 bool
 CMainWindow::RefreshView(ViewType Type)
 {
-    UINT CheckId;
+    UINT CheckId = 0;
     BOOL bSuccess;
 
     // Refreshed the cached view
@@ -312,7 +312,7 @@ CMainWindow::CreateStatusBar()
     return bRet;
 }
 
-void CMainWindow::UpdateToolbar(_In_ LPTV_ITEMW TvItem)
+void CMainWindow::UpdateToolbar()
 {
     WORD State;
 
@@ -466,14 +466,12 @@ CMainWindow::OnNotify(LPARAM lParam)
     {
         case TVN_SELCHANGED:
         {
-            LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam;
-            UpdateToolbar(&NmTreeView->itemNew);
+            UpdateToolbar();
             break;
         }
 
         case NM_DBLCLK:
         {
-            LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam;
             m_DeviceView->DisplayPropertySheet();
             break;
         }
@@ -531,7 +529,7 @@ CMainWindow::OnContext(LPARAM lParam)
 
 LRESULT
 CMainWindow::OnCommand(WPARAM wParam,
-                       LPARAM lParam)
+                       LPARAM /*lParam*/)
 {
     LRESULT RetCode = 0;
     WORD Msg;
@@ -792,9 +790,9 @@ HANDLE ProcessHeap = NULL;
 
 BOOL
 WINAPI
-DeviceManager_ExecuteW(HWND hWndParent,
+DeviceManager_ExecuteW(HWND /*hWndParent*/,
                        HINSTANCE hInst,
-                       LPCWSTR lpMachineName,
+                       LPCWSTR /*lpMachineName*/,
                        int nCmdShow)
 {
     CMainWindow MainWindow;
index b4920c6..75027b9 100644 (file)
@@ -46,7 +46,6 @@ private:
     bool CreateStatusBar();
 
     void UpdateToolbar(
-        _In_ LPTV_ITEMW TvItem
         );
 
     bool StatusBarLoadString(
index 5d1d5ef..6e3b099 100644 (file)
@@ -2,7 +2,7 @@
 * PROJECT:     ReactOS Device Manager
 * LICENSE:     GPL - See COPYING in the top level directory
 * FILE:        dll/win32/devmgr/devmgr/node.cpp
-* PURPOSE:     Object for each device in the tree
+* PURPOSE:     Abstract base object for each node in the tree
 * COPYRIGHT:   Copyright 2015 Ged Murphy <gedmurphy@reactos.org>
 *
 */
index bea3840..b200ba6 100644 (file)
@@ -34,11 +34,6 @@ public:
     LPWSTR GetDisplayName() { return m_DisplayName; }
     INT GetClassImage() { return m_ClassImage; }
     LPWSTR GetDeviceId() { return m_DeviceId; }
-
     bool HasProperties() { return (m_DeviceId != NULL); }
-
-private:
-    void Cleanup();
-
 };
 
index ba1fc80..05be76d 100644 (file)
@@ -53,7 +53,7 @@ CRootNode::SetupNode()
     // The root name is the computer name 
     DWORD Size = DISPLAY_NAME_LEN;
     if (GetComputerNameW(m_DisplayName, &Size))
-        _wcslwr_s(m_DisplayName);
+        _wcslwr(m_DisplayName);
 
     return true;
 
index e233e57..8802296 100644 (file)
@@ -1,6 +1,6 @@
 #pragma once
 
-#ifndef __REACTOS___
+#ifndef __REACTOS__
 
 #define WIN32_LEAN_AND_MEAN
 #include <Windows.h>
 #include <devguid.h>
 #include <process.h>
 
+
 #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
 #include <tchar.h>
 #include <atlbase.h>
 #include <atlstr.h>
 #include <atlcoll.h>
 
+#include <strsafe.h>
 #else
 
-#include <tchar.h>
+#include <string.h>
+#include <wchar.h>
 
+#include <tchar.h>
 #include <windef.h>
 #include <winbase.h>
 #include <winreg.h>
 #include <shlwapi.h>
 #include <strsafe.h>
 #include <process.h>
-
-#include <string.h>
-#include <wchar.h>
+#include <WindowsX.h>
+#include <strsafe.h>
 
 #include <setupapi.h>
 #include <commctrl.h>
 #include <cfgmgr32.h>
 #include <Uxtheme.h>
+#include <devguid.h>
 
 #include <atlbase.h>
-#include <atlcom.h>
-#include <atlwin.h>
 #include <atlstr.h>
+#include <atlcoll.h>
 
 #endif
\ No newline at end of file