-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscRecorder.cpp
More file actions
186 lines (159 loc) · 4.26 KB
/
DiscRecorder.cpp
File metadata and controls
186 lines (159 loc) · 4.26 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// DiscRecorder.cpp : implementation file
//
#include "pch.h"
#include "CdBurnApp.h"
#include "DiscRecorder.h"
// DiscRecorder
DiscRecorder::DiscRecorder() : m_recorder(NULL), m_volumePathNames(NULL)
{
}
DiscRecorder::~DiscRecorder()
{
if (m_recorder != NULL)
m_recorder->Release();
}
bool DiscRecorder::initialize(const CString& recorderUniqueId) {
m_recorderUniqueId = recorderUniqueId;
if (m_recorder == NULL)
{
m_result = CoCreateInstance(__uuidof(MsftDiscRecorder2), NULL, CLSCTX_INPROC_SERVER,
__uuidof(IDiscRecorder2), (void**)&m_recorder);
if (SUCCEEDED(m_result))
{
m_result = m_recorder->InitializeDiscRecorder(m_recorderUniqueId.AllocSysString());
if (SUCCEEDED(m_result)) {
m_result = m_recorder->get_VolumePathNames(&m_volumePathNames);
return true;
}
}
m_errorMessage.Format(_T("Couldn't initialize the IDiscRecorder2 - Error:0x%08x"), m_result); //create a error message that show hresult code of error in hex format
return false;
}
return false;
}
bool DiscRecorder::AcquireExclusiveAccess(bool force, const CString& clientName) {
if (m_recorder != NULL) {
force = force ? VARIANT_TRUE : VARIANT_FALSE;
m_result = m_recorder->AcquireExclusiveAccess(force, clientName.AllocSysString());
if (SUCCEEDED(m_result))
return true;;
}
m_errorMessage.Format(_T("AcquireExclusiveAccess error IDiscRecorder2 - Error:0x%08x"), m_result);
return false;
}
bool DiscRecorder::ReleaseExclusiveAccess() {
if (m_recorder != NULL) {
m_result = m_recorder->ReleaseExclusiveAccess();
if (SUCCEEDED(m_result)) {
return true;
}
}
m_errorMessage.Format(_T("ReleaseExclusiveAccess error IDiscRecorder2 - Error:0x%08x"), m_result);
return false;
}
CString DiscRecorder::ExclusiveAccessOwner() {
if (m_recorder != NULL) {
BSTR owner;
m_result = m_recorder->get_ExclusiveAccessOwner(&owner);
if (SUCCEEDED(m_result)) {
return owner;
}
return _T("");
}
}
bool DiscRecorder::EjectMedia() {
if (m_recorder != NULL) {
m_result = m_recorder->EjectMedia();
if (SUCCEEDED(m_result)) {
return true;
}
}
m_errorMessage.Format(_T("EjectMedia error IDiscRecorder2 - Error:0x%08x"), m_result);
return false;
}
bool DiscRecorder::CloseTray() {
if (m_recorder != NULL)
{
m_result = m_recorder->CloseTray();
if (SUCCEEDED(m_result))
{
return true;
}
}
m_errorMessage.Format(_T("CloseTray error IDiscRecorder2 - Error:0x%08x"), m_result);
return false;
}
bool DiscRecorder::EnableMcn() {
if (m_recorder != NULL)
{
m_result = m_recorder->EnableMcn();
if (SUCCEEDED(m_result))
{
return true;
}
}
m_errorMessage.Format(_T("EnableMcn error IDiscRecorder2 - Error:0x%08x"), m_result);
return false;
}
bool DiscRecorder::DisableMcn() {
if (m_recorder != NULL) {
m_result = m_recorder->DisableMcn();
if (SUCCEEDED(m_result))
{
return true;
}
m_errorMessage.Format(_T("DisableMcn error IDiscRecorder2 - Error:0x%08x"), m_result);
}
}
LONG DiscRecorder::GetLegacyNumber() {
if (m_recorder != NULL) {
LONG legacyNumber = 0;
m_result = m_recorder->get_LegacyDeviceNumber(&legacyNumber);
return legacyNumber;
}
}
CString DiscRecorder::GetProductID() {
BSTR productId = NULL;
if (m_recorder != NULL)
{
m_recorder->get_ProductId(&productId);
}
return productId;
}
CString DiscRecorder::GetProductRevision() {
BSTR productRevision = NULL;
if (m_recorder != NULL)
{
m_recorder->get_ProductId(&productRevision);
}
return productRevision;
}
CString DiscRecorder::GetVolumeName() {
BSTR volumeName = NULL;
if (m_recorder != NULL)
{
m_recorder->get_ProductId(&volumeName);
}
return volumeName;
}
CString DiscRecorder::GetVendorID() {
BSTR vendorId = NULL;
if (m_recorder != NULL)
{
m_recorder->get_ProductId(&vendorId);
}
return vendorId;
}
ULONG DiscRecorder::GetTotalVolumePaths() {
if (m_volumePathNames != NULL)
{
return m_volumePathNames->rgsabound[0].cElements; //which holds the count of elements in the array
}
return 0;
}
CString DiscRecorder::GetVolumePath(ULONG index) {
if (index < m_volumePathNames->rgsabound[0].cElements) {
return ((VARIANT*)(m_volumePathNames->pvData))[index].bstrVal; //List of drive letters and NTFS mount points for the device. Each element of the list is a VARIANT of type VT_BSTR. The bstrVal member of the variant contains the path.
}
return _T("");
}