@@ -181,34 +181,40 @@ class DialogWrapper {
181
181
Pointer <Pointer <COMObject >> shellItemArrayPtr,
182
182
Pointer <Uint32 > shellItemCountPtr,
183
183
Pointer <Pointer <COMObject >> shellItemPtr) {
184
- final List <String > files = < String > [];
185
- if (_isOpenDialog) {
186
- _lastResult = _dialogController.getResults (shellItemArrayPtr);
187
- if (! SUCCEEDED (_lastResult)) {
188
- return null ;
189
- }
184
+ try {
185
+ final List <String > files = < String > [];
186
+ int lastOperationResult;
187
+ if (_isOpenDialog) {
188
+ lastOperationResult = _dialogController.getResults (shellItemArrayPtr);
189
+ if (! SUCCEEDED (lastOperationResult)) {
190
+ throw WindowsException (lastOperationResult);
191
+ }
190
192
191
- final IShellItemArray shellItemResources =
192
- IShellItemArray (shellItemArrayPtr.cast ());
193
- _lastResult = shellItemResources.getCount (shellItemCountPtr);
194
- if (! SUCCEEDED (_lastResult)) {
195
- return null ;
196
- }
197
- for (int index = 0 ; index < shellItemCountPtr.value; index += 1 ) {
198
- shellItemResources.getItemAt (index, shellItemPtr);
193
+ final IShellItemArray shellItemResources =
194
+ IShellItemArray (shellItemArrayPtr.cast ());
195
+ lastOperationResult = shellItemResources.getCount (shellItemCountPtr);
196
+ if (! SUCCEEDED (lastOperationResult)) {
197
+ throw WindowsException (lastOperationResult);
198
+ }
199
+ for (int index = 0 ; index < shellItemCountPtr.value; index += 1 ) {
200
+ shellItemResources.getItemAt (index, shellItemPtr);
201
+ final IShellItem shellItem = IShellItem (shellItemPtr.cast ());
202
+ files.add (_shellWin32Api.getPathForShellItem (shellItem));
203
+ _shellWin32Api.releaseShellItem (shellItem);
204
+ }
205
+ } else {
206
+ lastOperationResult = _dialogController.getResult (shellItemPtr);
207
+ if (! SUCCEEDED (lastOperationResult)) {
208
+ throw WindowsException (lastOperationResult);
209
+ }
199
210
final IShellItem shellItem = IShellItem (shellItemPtr.cast ());
200
211
files.add (_shellWin32Api.getPathForShellItem (shellItem));
201
212
_shellWin32Api.releaseShellItem (shellItem);
202
213
}
203
- } else {
204
- _lastResult = _dialogController.getResult (shellItemPtr);
205
- if (! SUCCEEDED (_lastResult)) {
206
- return null ;
207
- }
208
- final IShellItem shellItem = IShellItem (shellItemPtr.cast ());
209
- files.add (_shellWin32Api.getPathForShellItem (shellItem));
210
- _shellWin32Api.releaseShellItem (shellItem);
214
+ return files;
215
+ } on WindowsException catch (ex) {
216
+ _lastResult = ex.hr;
217
+ return null ;
211
218
}
212
- return files;
213
219
}
214
220
}
0 commit comments