-
Notifications
You must be signed in to change notification settings - Fork 29
/
COpenFileListener.cpp
108 lines (86 loc) · 2.12 KB
/
COpenFileListener.cpp
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
#ifdef UNICODE
#include "COpenFileListener.h"
STDMETHODIMP COpenFileListener::OnFileOk(IFileDialog* pfd)
{
IShellItemArray *psiaResults;
IFileDialogCustomize *pfdc;
HRESULT hr;
IFileOpenDialog *fod;
FILEINFO fileinfoTmp = {0};
DWORD choice;
fileinfoTmp.parentList = pFInfoList;
hr = pfd->QueryInterface(IID_PPV_ARGS(&fod));
if(SUCCEEDED(hr)) {
hr = fod->GetSelectedItems(&psiaResults);
if (SUCCEEDED(hr)) {
DWORD fileCount;
IShellItem *isi;
LPWSTR pwsz = NULL;
psiaResults->GetCount(&fileCount);
for(DWORD i=0;i<fileCount;i++) {
psiaResults->GetItemAt(i,&isi);
isi->GetDisplayName(SIGDN_FILESYSPATH,&pwsz);
isi->Release();
fileinfoTmp.szFilename = pwsz;
pFInfoList->fInfos.push_back(fileinfoTmp);
CoTaskMemFree(pwsz);
}
psiaResults->Release();
}
fod->Release();
}
hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdc));
if(SUCCEEDED(hr)) {
hr = pfdc->GetSelectedControlItem(FDIALOG_OPENCHOICES,&choice);
if(SUCCEEDED(hr)) {
if(choice==FDIALOG_CHOICE_REPARENT) {
pFInfoList->uiCmdOpts = CMD_REPARENT;
}
else if(choice==FDIALOG_CHOICE_ALLHASHES) {
pFInfoList->uiCmdOpts = CMD_ALLHASHES;
}
else if(choice==FDIALOG_CHOICE_BSD) {
pFInfoList->uiCmdOpts = CMD_FORCE_BSD;
}
else if(choice == FDIALOG_CHOICE_NORMAL) {
pFInfoList->uiCmdOpts = CMD_FORCE_NORMAL;
}
}
pfdc->Release();
}
return S_OK;
}
COpenFileListener::COpenFileListener(lFILEINFO *pFInfoList)
{
m_cRef = 0L;
this->pFInfoList = pFInfoList;
}
COpenFileListener::~COpenFileListener()
{
}
STDMETHODIMP COpenFileListener::QueryInterface(REFIID riid, LPVOID *ppv)
{
*ppv = NULL;
if (IsEqualIID(riid, IID_IFileDialogEvents) || IsEqualIID(riid, IID_IUnknown))
{
*ppv = (IFileDialogEvents *)this;
}
if (*ppv)
{
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) COpenFileListener::AddRef()
{
return ++m_cRef;
}
STDMETHODIMP_(ULONG) COpenFileListener::Release()
{
if (--m_cRef)
return m_cRef;
delete this;
return 0L;
}
#endif