]> git.saurik.com Git - wxWidgets.git/blame - src/msw/volume.cpp
implement editing_started and _done events for GTK+ >= 2.6
[wxWidgets.git] / src / msw / volume.cpp
CommitLineData
7183fd72
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/volume.cpp
3// Purpose: wxFSVolume - encapsulates system volume information
4// Author: George Policello
5// Modified by:
6// Created: 28 Jan 02
7// RCS-ID: $Id$
8// Copyright: (c) 2002 George Policello
65571936 9// Licence: wxWindows licence
7183fd72
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
7183fd72
VZ
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
05815ab3
VZ
26#if wxUSE_FSVOLUME
27
7212d155
PC
28#include "wx/volume.h"
29
7183fd72 30#ifndef WX_PRECOMP
df5168c4
MB
31 #if wxUSE_GUI
32 #include "wx/icon.h"
33 #endif
05815ab3 34 #include "wx/intl.h"
df69528b 35 #include "wx/hashmap.h"
7183fd72
VZ
36#endif // WX_PRECOMP
37
38#include "wx/dir.h"
7183fd72
VZ
39#include "wx/dynlib.h"
40#include "wx/arrimpl.cpp"
41
eaeeb91e 42#include <shellapi.h>
a6c7a0f8 43#include <shlobj.h>
7212d155 44#include "wx/msw/missing.h"
eaeeb91e 45
ec67cff1 46#if wxUSE_BASE
7cfdeaad 47
7183fd72
VZ
48//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49// Dynamic library function defs.
50//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51
64c288fa 52#if wxUSE_DYNLIB_CLASS
7183fd72 53static wxDynamicLibrary s_mprLib;
64c288fa 54#endif
7183fd72
VZ
55
56typedef DWORD (WINAPI* WNetOpenEnumPtr)(DWORD, DWORD, DWORD, LPNETRESOURCE, LPHANDLE);
57typedef DWORD (WINAPI* WNetEnumResourcePtr)(HANDLE, LPDWORD, LPVOID, LPDWORD);
58typedef DWORD (WINAPI* WNetCloseEnumPtr)(HANDLE);
59
60static WNetOpenEnumPtr s_pWNetOpenEnum;
61static WNetEnumResourcePtr s_pWNetEnumResource;
62static WNetCloseEnumPtr s_pWNetCloseEnum;
63
64//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
65// Globals/Statics
66//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67static long s_cancelSearch = FALSE;
68
17ebae65 69struct FileInfo
7183fd72
VZ
70{
71 FileInfo(unsigned flag=0, wxFSVolumeKind type=wxFS_VOL_OTHER) :
72 m_flags(flag), m_type(type) {}
51fdd3da
VZ
73
74 FileInfo(const FileInfo& other) { *this = other; }
75 FileInfo& operator=(const FileInfo& other)
76 {
77 m_flags = other.m_flags;
78 m_type = other.m_type;
79 return *this;
80 }
81
7183fd72
VZ
82 unsigned m_flags;
83 wxFSVolumeKind m_type;
84};
85WX_DECLARE_STRING_HASH_MAP(FileInfo, FileInfoMap);
17ebae65
MB
86// Cygwin bug (?) destructor for global s_fileInfo is called twice...
87static FileInfoMap& GetFileInfoMap()
88{
89 static FileInfoMap s_fileInfo(25);
90
91 return s_fileInfo;
92}
93#define s_fileInfo (GetFileInfoMap())
7183fd72 94
7183fd72
VZ
95//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96// Local helper functions.
97//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
98
99//=============================================================================
100// Function: GetBasicFlags
101// Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.
102// Notes: - Local and mapped drives are mounted by definition. We have no
103// way to determine mounted status of network drives, so assume that
104// all drives are mounted, and let the caller decide otherwise.
105// - Other flags are 'best guess' from type of drive. The system will
106// not report the file attributes with any degree of accuracy.
107//=============================================================================
4d90b8de 108static unsigned GetBasicFlags(const wxChar* filename)
7183fd72
VZ
109{
110 unsigned flags = wxFS_VOL_MOUNTED;
111
112 //----------------------------------
113 // 'Best Guess' based on drive type.
114 //----------------------------------
115 wxFSVolumeKind type;
116 switch(GetDriveType(filename))
117 {
118 case DRIVE_FIXED:
119 type = wxFS_VOL_DISK;
120 break;
121
122 case DRIVE_REMOVABLE:
123 flags |= wxFS_VOL_REMOVABLE;
124 type = wxFS_VOL_FLOPPY;
125 break;
126
127 case DRIVE_CDROM:
128 flags |= wxFS_VOL_REMOVABLE | wxFS_VOL_READONLY;
129 type = wxFS_VOL_CDROM;
130 break;
131
132 case DRIVE_REMOTE:
133 flags |= wxFS_VOL_REMOTE;
134 type = wxFS_VOL_NETWORK;
135 break;
136
137 case DRIVE_NO_ROOT_DIR:
138 flags &= ~wxFS_VOL_MOUNTED;
139 type = wxFS_VOL_OTHER;
140 break;
141
142 default:
143 type = wxFS_VOL_OTHER;
144 break;
145 }
146
147 //-----------------------------------------------------------------------
90e572f1 148 // The following most likely will not modify anything not set above,
7183fd72
VZ
149 // and will not work at all for network shares or empty CD ROM drives.
150 // But it is a good check if the Win API ever gets better about reporting
151 // this information.
152 //-----------------------------------------------------------------------
153 SHFILEINFO fi;
ab63e6ae 154 long rc = SHGetFileInfo(filename, 0, &fi, sizeof(fi), SHGFI_ATTRIBUTES);
7183fd72
VZ
155 if (!rc)
156 {
ab63e6ae
VZ
157 // this error is not fatal, so don't show a message to the user about
158 // it, otherwise it would appear every time a generic directory picker
159 // dialog is used and there is a connected network drive
160 wxLogLastError(_T("SHGetFileInfo"));
7183fd72
VZ
161 }
162 else
163 {
164 if (fi.dwAttributes & SFGAO_READONLY)
165 flags |= wxFS_VOL_READONLY;
166 if (fi.dwAttributes & SFGAO_REMOVABLE)
167 flags |= wxFS_VOL_REMOVABLE;
168 }
169
170 //------------------
171 // Flags are cached.
172 //------------------
173 s_fileInfo[filename] = FileInfo(flags, type);
174
175 return flags;
176} // GetBasicFlags
177
178//=============================================================================
179// Function: FilteredAdd
180// Purpose: Add a file to the list if it meets the filter requirement.
181// Notes: - See GetBasicFlags for remarks about the Mounted flag.
182//=============================================================================
27d2dbbc 183static bool FilteredAdd(wxArrayString& list, const wxChar* filename,
4d90b8de 184 unsigned flagsSet, unsigned flagsUnset)
7183fd72 185{
27d2dbbc 186 bool accept = true;
7183fd72
VZ
187 unsigned flags = GetBasicFlags(filename);
188
189 if (flagsSet & wxFS_VOL_MOUNTED && !(flags & wxFS_VOL_MOUNTED))
27d2dbbc 190 accept = false;
7183fd72 191 else if (flagsUnset & wxFS_VOL_MOUNTED && (flags & wxFS_VOL_MOUNTED))
27d2dbbc 192 accept = false;
7183fd72 193 else if (flagsSet & wxFS_VOL_REMOVABLE && !(flags & wxFS_VOL_REMOVABLE))
27d2dbbc 194 accept = false;
7183fd72 195 else if (flagsUnset & wxFS_VOL_REMOVABLE && (flags & wxFS_VOL_REMOVABLE))
27d2dbbc 196 accept = false;
7183fd72 197 else if (flagsSet & wxFS_VOL_READONLY && !(flags & wxFS_VOL_READONLY))
27d2dbbc 198 accept = false;
7183fd72 199 else if (flagsUnset & wxFS_VOL_READONLY && (flags & wxFS_VOL_READONLY))
27d2dbbc 200 accept = false;
7183fd72 201 else if (flagsSet & wxFS_VOL_REMOTE && !(flags & wxFS_VOL_REMOTE))
27d2dbbc 202 accept = false;
7183fd72 203 else if (flagsUnset & wxFS_VOL_REMOTE && (flags & wxFS_VOL_REMOTE))
27d2dbbc 204 accept = false;
7183fd72
VZ
205
206 // Add to the list if passed the filter.
207 if (accept)
208 list.Add(filename);
209
210 return accept;
211} // FilteredAdd
212
213//=============================================================================
214// Function: BuildListFromNN
215// Purpose: Append or remove items from the list
216// Notes: - There is no way to find all disconnected NN items, or even to find
217// all items while determining which are connected and not. So this
218// function will find either all items or connected items.
219//=============================================================================
27d2dbbc 220static void BuildListFromNN(wxArrayString& list, NETRESOURCE* pResSrc,
4d90b8de 221 unsigned flagsSet, unsigned flagsUnset)
7183fd72
VZ
222{
223 HANDLE hEnum;
224 int rc;
225
226 //-----------------------------------------------
227 // Scope may be all drives or all mounted drives.
228 //-----------------------------------------------
229 unsigned scope = RESOURCE_GLOBALNET;
230 if (flagsSet & wxFS_VOL_MOUNTED)
231 scope = RESOURCE_CONNECTED;
232
233 //----------------------------------------------------------------------
234 // Enumerate all items, adding only non-containers (ie. network shares).
235 // Containers cause a recursive call to this function for their own
236 // enumeration.
237 //----------------------------------------------------------------------
238 if (rc = s_pWNetOpenEnum(scope, RESOURCETYPE_DISK, 0, pResSrc, &hEnum), rc == NO_ERROR)
239 {
4aebbc59
MB
240 DWORD count = 1;
241 DWORD size = 256;
7183fd72
VZ
242 NETRESOURCE* pRes = (NETRESOURCE*)malloc(size);
243 memset(pRes, 0, sizeof(NETRESOURCE));
244 while (rc = s_pWNetEnumResource(hEnum, &count, pRes, &size), rc == NO_ERROR || rc == ERROR_MORE_DATA)
245 {
246 if (s_cancelSearch)
247 break;
248
249 if (rc == ERROR_MORE_DATA)
250 {
251 pRes = (NETRESOURCE*)realloc(pRes, size);
252 count = 1;
253 }
254 else if (count == 1)
255 {
256 // Enumerate the container.
257 if (pRes->dwUsage & RESOURCEUSAGE_CONTAINER)
258 {
259 BuildListFromNN(list, pRes, flagsSet, flagsUnset);
260 }
261
262 // Add the network share.
263 else
264 {
265 wxString filename(pRes->lpRemoteName);
266
df69528b 267 if (!filename.empty())
7183fd72
VZ
268 {
269 if (filename.Last() != '\\')
270 filename.Append('\\');
271
272 // The filter function will not know mounted from unmounted, and neither do we unless
273 // we are iterating using RESOURCE_CONNECTED, in which case they all are mounted.
274 // Volumes on disconnected servers, however, will correctly show as unmounted.
17a691c1 275 FilteredAdd(list, filename.wx_str(), flagsSet, flagsUnset&~wxFS_VOL_MOUNTED);
7183fd72
VZ
276 if (scope == RESOURCE_GLOBALNET)
277 s_fileInfo[filename].m_flags &= ~wxFS_VOL_MOUNTED;
278 }
279 }
280 }
281 else if (count == 0)
282 break;
283 }
284 free(pRes);
285 s_pWNetCloseEnum(hEnum);
286 }
287} // BuildListFromNN
288
289//=============================================================================
290// Function: CompareFcn
291// Purpose: Used to sort the NN list alphabetically, case insensitive.
292//=============================================================================
99f161bd 293static int CompareFcn(const wxString& first, const wxString& second)
7183fd72 294{
99f161bd 295 return wxStricmp(first.c_str(), second.c_str());
7183fd72
VZ
296} // CompareFcn
297
298//=============================================================================
299// Function: BuildRemoteList
300// Purpose: Append Network Neighborhood items to the list.
301// Notes: - Mounted gets transalated into Connected. FilteredAdd is told
302// to ignore the Mounted flag since we need to handle it in a weird
303// way manually.
304// - The resulting list is sorted alphabetically.
305//=============================================================================
27d2dbbc 306static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc,
4d90b8de 307 unsigned flagsSet, unsigned flagsUnset)
7183fd72
VZ
308{
309 // NN query depends on dynamically loaded library.
310 if (!s_pWNetOpenEnum || !s_pWNetEnumResource || !s_pWNetCloseEnum)
311 {
312 wxLogError(_("Failed to load mpr.dll."));
27d2dbbc 313 return false;
7183fd72
VZ
314 }
315
316 // Don't waste time doing the work if the flags conflict.
317 if (flagsSet & wxFS_VOL_MOUNTED && flagsUnset & wxFS_VOL_MOUNTED)
27d2dbbc 318 return false;
7183fd72
VZ
319
320 //----------------------------------------------
321 // Generate the list according to the flags set.
322 //----------------------------------------------
323 BuildListFromNN(list, pResSrc, flagsSet, flagsUnset);
324 list.Sort(CompareFcn);
325
326 //-------------------------------------------------------------------------
327 // If mounted only is requested, then we only need one simple pass.
328 // Otherwise, we need to build a list of all NN volumes and then apply the
329 // list of mounted drives to it.
330 //-------------------------------------------------------------------------
331 if (!(flagsSet & wxFS_VOL_MOUNTED))
332 {
333 // generate.
334 wxArrayString mounted;
335 BuildListFromNN(mounted, pResSrc, flagsSet | wxFS_VOL_MOUNTED, flagsUnset & ~wxFS_VOL_MOUNTED);
336 mounted.Sort(CompareFcn);
337
338 // apply list from bottom to top to preserve indexes if removing items.
4a559093
WS
339 ssize_t iList = list.GetCount()-1;
340 for (ssize_t iMounted = mounted.GetCount()-1; iMounted >= 0 && iList >= 0; iMounted--)
7183fd72
VZ
341 {
342 int compare;
343 wxString all(list[iList]);
344 wxString mount(mounted[iMounted]);
345
27d2dbbc 346 while (compare =
4d90b8de
VS
347 wxStricmp(list[iList].c_str(), mounted[iMounted].c_str()),
348 compare > 0 && iList >= 0)
7183fd72
VZ
349 {
350 iList--;
351 all = list[iList];
352 }
353
354
355 if (compare == 0)
356 {
357 // Found the element. Remove it or mark it mounted.
358 if (flagsUnset & wxFS_VOL_MOUNTED)
ba8c1601 359 list.RemoveAt(iList);
7183fd72
VZ
360 else
361 s_fileInfo[list[iList]].m_flags |= wxFS_VOL_MOUNTED;
362
363 }
364
365 iList--;
366 }
367 }
368
27d2dbbc 369 return true;
7183fd72
VZ
370} // BuildRemoteList
371
372//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
373// wxFSVolume
374//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
375
376//=============================================================================
377// Function: GetVolumes
378// Purpose: Generate and return a list of all volumes (drives) available.
379// Notes:
380//=============================================================================
e2478fde 381wxArrayString wxFSVolumeBase::GetVolumes(int flagsSet, int flagsUnset)
7183fd72 382{
27d2dbbc 383 ::InterlockedExchange(&s_cancelSearch, FALSE); // reset
7183fd72 384
64c288fa 385#if wxUSE_DYNLIB_CLASS
7183fd72
VZ
386 if (!s_mprLib.IsLoaded() && s_mprLib.Load(_T("mpr.dll")))
387 {
388#ifdef UNICODE
389 s_pWNetOpenEnum = (WNetOpenEnumPtr)s_mprLib.GetSymbol(_T("WNetOpenEnumW"));
2b5f62a0 390 s_pWNetEnumResource = (WNetEnumResourcePtr)s_mprLib.GetSymbol(_T("WNetEnumResourceW"));
7183fd72
VZ
391#else
392 s_pWNetOpenEnum = (WNetOpenEnumPtr)s_mprLib.GetSymbol(_T("WNetOpenEnumA"));
393 s_pWNetEnumResource = (WNetEnumResourcePtr)s_mprLib.GetSymbol(_T("WNetEnumResourceA"));
394#endif
395 s_pWNetCloseEnum = (WNetCloseEnumPtr)s_mprLib.GetSymbol(_T("WNetCloseEnum"));
396 }
64c288fa 397#endif
7183fd72
VZ
398
399 wxArrayString list;
400
401 //-------------------------------
402 // Local and mapped drives first.
403 //-------------------------------
404 // Allocate the required space for the API call.
95dc6a2b 405 const DWORD chars = GetLogicalDriveStrings(0, NULL);
7183fd72
VZ
406 TCHAR* buf = new TCHAR[chars+1];
407
408 // Get the list of drives.
999836aa 409 GetLogicalDriveStrings(chars, buf);
7183fd72
VZ
410
411 // Parse the list into an array, applying appropriate filters.
412 TCHAR *pVol;
413 pVol = buf;
414 while (*pVol)
415 {
416 FilteredAdd(list, pVol, flagsSet, flagsUnset);
67fade33 417 pVol = pVol + wxStrlen(pVol) + 1;
7183fd72
VZ
418 }
419
420 // Cleanup.
421 delete[] buf;
422
423 //---------------------------
424 // Network Neighborhood next.
425 //---------------------------
426
427 // not exclude remote and not removable
428 if (!(flagsUnset & wxFS_VOL_REMOTE) &&
429 !(flagsSet & wxFS_VOL_REMOVABLE)
430 )
431 {
432 // The returned list will be sorted alphabetically. We don't pass
433 // our in since we don't want to change to order of the local drives.
434 wxArrayString nn;
435 if (BuildRemoteList(nn, 0, flagsSet, flagsUnset))
436 {
89c98653 437 for (size_t idx = 0; idx < nn.GetCount(); idx++)
7183fd72
VZ
438 list.Add(nn[idx]);
439 }
440 }
441
442 return list;
443} // GetVolumes
444
445//=============================================================================
446// Function: CancelSearch
447// Purpose: Instruct an active search to stop.
448// Notes: - This will only sensibly be called by a thread other than the one
449// performing the search. This is the only thread-safe function
450// provided by the class.
451//=============================================================================
e2478fde 452void wxFSVolumeBase::CancelSearch()
7183fd72 453{
27d2dbbc 454 ::InterlockedExchange(&s_cancelSearch, TRUE);
7183fd72
VZ
455} // CancelSearch
456
457//=============================================================================
458// Function: constructor
459// Purpose: default constructor
460//=============================================================================
e2478fde 461wxFSVolumeBase::wxFSVolumeBase()
7183fd72 462{
27d2dbbc 463 m_isOk = false;
7183fd72
VZ
464} // wxVolume
465
466//=============================================================================
467// Function: constructor
468// Purpose: constructor that calls Create
469//=============================================================================
e2478fde 470wxFSVolumeBase::wxFSVolumeBase(const wxString& name)
7183fd72
VZ
471{
472 Create(name);
473} // wxVolume
474
475//=============================================================================
476// Function: Create
477// Purpose: Finds, logs in, etc. to the request volume.
478//=============================================================================
e2478fde 479bool wxFSVolumeBase::Create(const wxString& name)
7183fd72
VZ
480{
481 // assume fail.
27d2dbbc 482 m_isOk = false;
7183fd72
VZ
483
484 // supplied.
485 m_volName = name;
486
487 // Display name.
488 SHFILEINFO fi;
17a691c1 489 long rc = SHGetFileInfo(m_volName.wx_str(), 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME);
7183fd72
VZ
490 if (!rc)
491 {
4d90b8de 492 wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());
7183fd72
VZ
493 return m_isOk;
494 }
495 m_dispName = fi.szDisplayName;
496
7183fd72 497 // all tests passed.
27d2dbbc 498 return m_isOk = true;
7183fd72
VZ
499} // Create
500
501//=============================================================================
502// Function: IsOk
27d2dbbc 503// Purpose: returns true if the volume is legal.
7183fd72
VZ
504// Notes: For fixed disks, it must exist. For removable disks, it must also
505// be present. For Network Shares, it must also be logged in, etc.
506//=============================================================================
e2478fde 507bool wxFSVolumeBase::IsOk() const
7183fd72
VZ
508{
509 return m_isOk;
510} // IsOk
511
512//=============================================================================
513// Function: GetKind
514// Purpose: Return the type of the volume.
515//=============================================================================
e2478fde 516wxFSVolumeKind wxFSVolumeBase::GetKind() const
7183fd72
VZ
517{
518 if (!m_isOk)
519 return wxFS_VOL_OTHER;
520
521 FileInfoMap::iterator itr = s_fileInfo.find(m_volName);
522 if (itr == s_fileInfo.end())
523 return wxFS_VOL_OTHER;
524
525 return itr->second.m_type;
526}
527
528//=============================================================================
529// Function: GetFlags
530// Purpose: Return the caches flags for this volume.
531// Notes: - Returns -1 if no flags were cached.
532//=============================================================================
e2478fde 533int wxFSVolumeBase::GetFlags() const
7183fd72
VZ
534{
535 if (!m_isOk)
536 return -1;
537
538 FileInfoMap::iterator itr = s_fileInfo.find(m_volName);
539 if (itr == s_fileInfo.end())
540 return -1;
541
542 return itr->second.m_flags;
543} // GetFlags
544
ec67cff1 545#endif // wxUSE_BASE
e2478fde
VZ
546
547// ============================================================================
548// wxFSVolume
549// ============================================================================
550
0e7fa3a6 551#if wxUSE_GUI
7183fd72 552
e2478fde
VZ
553void wxFSVolume::InitIcons()
554{
555 m_icons.Alloc(wxFS_VOL_ICO_MAX);
556 wxIcon null;
557 for (int idx = 0; idx < wxFS_VOL_ICO_MAX; idx++)
558 m_icons.Add(null);
559}
560
7183fd72
VZ
561//=============================================================================
562// Function: GetIcon
563// Purpose: return the requested icon.
564//=============================================================================
e2478fde 565
7183fd72
VZ
566wxIcon wxFSVolume::GetIcon(wxFSIconType type) const
567{
e2478fde
VZ
568 wxCHECK_MSG( type >= 0 && (size_t)type < m_icons.GetCount(), wxNullIcon,
569 _T("wxFSIconType::GetIcon(): invalid icon index") );
7183fd72
VZ
570
571 // Load on demand.
572 if (m_icons[type].IsNull())
573 {
e2478fde 574 UINT flags = SHGFI_ICON;
7183fd72
VZ
575 switch (type)
576 {
577 case wxFS_VOL_ICO_SMALL:
e2478fde 578 flags |= SHGFI_SMALLICON;
7183fd72
VZ
579 break;
580
581 case wxFS_VOL_ICO_LARGE:
e2478fde 582 flags |= SHGFI_SHELLICONSIZE;
7183fd72
VZ
583 break;
584
585 case wxFS_VOL_ICO_SEL_SMALL:
e2478fde 586 flags |= SHGFI_SMALLICON | SHGFI_OPENICON;
7183fd72
VZ
587 break;
588
589 case wxFS_VOL_ICO_SEL_LARGE:
e2478fde 590 flags |= SHGFI_SHELLICONSIZE | SHGFI_OPENICON;
7183fd72 591 break;
27d2dbbc 592
4d90b8de
VS
593 case wxFS_VOL_ICO_MAX:
594 wxFAIL_MSG(_T("wxFS_VOL_ICO_MAX is not valid icon type"));
595 break;
7183fd72
VZ
596 }
597
598 SHFILEINFO fi;
17a691c1 599 long rc = SHGetFileInfo(m_volName.wx_str(), 0, &fi, sizeof(fi), flags);
7183fd72
VZ
600 m_icons[type].SetHICON((WXHICON)fi.hIcon);
601 if (!rc || !fi.hIcon)
4d90b8de 602 wxLogError(_("Cannot load icon from '%s'."), m_volName.c_str());
7183fd72
VZ
603 }
604
605 return m_icons[type];
606} // GetIcon
607
608#endif // wxUSE_GUI
609
05815ab3 610#endif // wxUSE_FSVOLUME