e91b4d74a2d42d51865f2fbf1aa0fbfdf9352356
[reactos.git] / reactos / dll / win32 / devmgr / devmgmt / RootNode.cpp
1 /*
2 * PROJECT: ReactOS Device Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/devmgr/devmgmt/RootNode.cpp
5 * PURPOSE: Root object for
6 * COPYRIGHT: Copyright 2015 Ged Murphy <gedmurphy@reactos.org>
7 *
8 */
9
10 #include "precomp.h"
11 #include "devmgmt.h"
12 #include "RootNode.h"
13
14
15 CRootNode::CRootNode(_In_ PSP_CLASSIMAGELIST_DATA ImageListData) :
16 CNode(RootNode, ImageListData)
17 {
18 }
19
20
21 CRootNode::~CRootNode()
22 {
23 }
24
25
26 bool
27 CRootNode::SetupNode()
28 {
29
30 // Load the bitmap we'll be using as the root image
31 HBITMAP hRootImage;
32 hRootImage = LoadBitmapW(g_hThisInstance,
33 MAKEINTRESOURCEW(IDB_ROOT_IMAGE));
34 if (hRootImage == NULL) return FALSE;
35
36 // Add this bitmap to the device image list. This is a bit hacky, but it's safe
37 m_ClassImage = ImageList_Add(m_ImageListData->ImageList,
38 hRootImage,
39 NULL);
40 DeleteObject(hRootImage);
41
42
43 // Get the root instance
44 CONFIGRET cr;
45 cr = CM_Locate_DevNodeW(&m_DevInst,
46 NULL,
47 CM_LOCATE_DEVNODE_NORMAL);
48 if (cr != CR_SUCCESS)
49 {
50 return false;
51 }
52
53 // The root name is the computer name
54 DWORD Size = DISPLAY_NAME_LEN;
55 if (GetComputerNameW(m_DisplayName, &Size))
56 _wcslwr(m_DisplayName);
57
58 return true;
59 }