-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDeviceWatcher.cpp
More file actions
65 lines (53 loc) · 1.32 KB
/
Copy pathDeviceWatcher.cpp
File metadata and controls
65 lines (53 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "StdAfx.h"
#include "DeviceWatcher.h"
using namespace DeviceDetectLibrary;
using namespace DeviceDetectLibrary::Connection;
CDeviceWatcher::CDeviceWatcher(IDeviceWatcherObserver* observer)
: CAbstractDeviceWatcher(observer)
{
}
CDeviceWatcher::~CDeviceWatcher(void)
{
Stop();
}
void CDeviceWatcher::InterfaceArrival(const GUID& guid)
{
m_pUsbEnumerator->TryThis(guid);
}
void CDeviceWatcher::InterfaceRemoved(const std::wstring& devId)
{
Lost(devId);
}
void CDeviceWatcher::VolumeArrival(const std::wstring& devId)
{
if(NULL != m_pMsEnumerator.get())
{
m_pMsEnumerator->TryThis(devId);
}
}
void CDeviceWatcher::VolumeRemoved(const std::wstring& devId)
{
if(NULL != m_pMsEnumerator.get())
{
m_pMsEnumerator->RemoveThis(devId);
Lost(devId);
}
}
void CDeviceWatcher::StartEnumerators(void)
{
CNotifyWindow& window = CreateNotifyWindow();
// Create Enumerators
m_pUsbEnumerator = CUsbEnumerator::Create(window, *this);
CDeviceInfo::Pointer pDeviceInfo1 = CDeviceInfo::Create();
m_pUsbEnumerator->Collect(pDeviceInfo1);
m_pMsEnumerator = CMSEnumerator::Create(*this);
CDeviceInfo::Pointer pDeviceInfo2 = CDeviceInfo::Create();
m_pMsEnumerator->Collect(pDeviceInfo2);
}
void CDeviceWatcher::StopEnumerators(void)
{
RemoveNotifyWindow();
// Remove Enumerators
m_pUsbEnumerator.reset();
m_pMsEnumerator.reset();
}