windows - What is the correct way to detect that an IShellItem refers to a Library? -
i'm using common file dialog fos_pickfolders let user pick location save files. if user selects library, e.g. library\documents current code fails @ point call ishellitem::getdisplayname extract file system name. if item file succeed , library's default save location used.
what detect shell item library, obtain ishelllibrary interface, , query find default save location. save files there.
what correct way detect ishellitem refers library?
the way found use ishelllibrary::loadlibraryfromitem (msdn here), pass ishellitem interface.
if fails (i.e. hresult != s_ok), ishellitem not library.
so this:
bool islibrary(ishellitem *pitem) { bool bislibrary = false; ishelllibrary *plib = null; hresult hr = cocreateinstance(clsid_shelllibrary, null, clsctx_inproc_server, iid_ppv_args(&plib)); if (succeeded(hr)) { hr = plib->loadlibraryfromitem(pitem, stgm_read); if (succeeded(hr)) bislibrary = true; plib->release(); } return bislibrary; } i have no idea if it's "correct" way, may useful anyway.
Comments
Post a Comment