|
|
|
date: Sun, 06 Apr 2008 18:06:36 +0200,
group: microsoft.public.platformsdk.shell
back
Re: How to find the status of mapped drives
Jim Barry wrote:
> Hermann Schinagl wrote:
>> b) Ask explorer, because it might already know and
>> it keeps a statusinfo, because it did this
>> kind of getVolumeInformation() already
>>
>> Any calls available?
>
> Does SHGetDataFromIDList give you the info you need?
>
I have tried, and theoretically it could, but I was
up till now never able to successfully call SHGetDataFromIDList()
with SHGDFIL_NETRESOURCE.
I always get E_FAILED, which tells me that something is wrong
as mentioned in the docs, but how do I start with a drive, like
j:\ and end with the correct pidl so that SHGetDataFromIDList
succeeds with SHGDFIL_NETRESOURCE?
Any ideas?
Ciao Hermann
My Coding is the usual sample:
void EnumerateFolder()
{
LPMALLOC pMalloc = NULL; // memory manager, for freeing up PIDLs
HRESULT hr = SHGetMalloc(&pMalloc);
LPSHELLFOLDER psfDesktop = NULL; // namespace root for parsing the path
hr = SHGetDesktopFolder(&psfDesktop);
// parse path for absolute PIDL, and connect to target folder
LPITEMIDLIST pidl = NULL; // general purpose
hr = psfDesktop->ParseDisplayName(NULL, NULL, L"j:\\", NULL, &pidl,
NULL);
LPSHELLFOLDER psfFolder = NULL;
hr = psfDesktop->BindToObject(pidl, NULL, IID_IShellFolder,
(void**)&psfFolder);
pMalloc->Free(pidl);
LPENUMIDLIST penumIDL = NULL; // IEnumIDList interface for reading
contents
hr = psfFolder->EnumObjects(NULL, SHCONTF_FOLDERS |
SHCONTF_NONFOLDERS | SHCONTF_SHAREABLE, &penumIDL);
while(1) {
// retrieve a copy of next local item ID list
hr = penumIDL->Next(1, &pidl, NULL);
if(hr == NOERROR) {
struct : public NETRESOURCE
{
BYTE bytes[8192];
} nr;
hr = SHGetDataFromIDList(psfFolder, pidl, SHGDFIL_NETRESOURCE, &nr,
sizeof(nr));
if (SUCCEEDED(hr))
{
TRACE (L"Name = %s\n", nr.lpRemoteName);
}
pMalloc->Free(pidl);
}
// the expected "error" is S_FALSE, when the list is finished
else break;
}
// release all remaining interface pointers
penumIDL->Release();
psfFolder->Release();
psfDesktop->Release(); // no longer required
pMalloc->Release();
date: Tue, 08 Apr 2008 19:14:40 +0200
author: Hermann Schinagl
Re: How to find the status of mapped drives
Wouldn't GetLogicalDrives and GetDriveType provide you with the information
as to which drives are remote?
The WnetGetConnection function will tell you the status of a particular
remote drive(i.e., not connected, connection unavailable, etc.)
"Hermann Schinagl" wrote in message
news:uBs5xAAmIHA.3512@TK2MSFTNGP03.phx.gbl...
> Hi
>
> I have a shell extension, which implements an IconOverlay
> handler ( who does this not ;-), and to find out about
> the type of Filesystem I have to call GetVolumeInformation()
> on any drive the Overlay Handler asks me to.
> ( It asks me for all drives ...)
>
> But: GetVolumeInformations takes ages, when you call it
> on a mapped network drive, if the network drive is mapped
> but unavailable, lets call them zombie drives.
>
> I see two ways to solve this
>
> a) Have a *quick* way to probe the status of a network
> drive. BTW: NetGetResourceInformation() & friends
> takes also ages.
>
> Any ideas?
>
> b) Ask explorer, because it might already know and
> it keeps a statusinfo, because it did this
> kind of getVolumeInformation() already
>
> Any calls available?
>
> This must be a common problem to all authors of
> shell extensions..
>
> Any help appreciated!
>
> Ciao and thanks
>
> Hermann
date: Tue, 8 Apr 2008 18:18:17 -0400
author: Michael Phillips, Jr. 0.c0m
|
|