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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -