Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Sun, 06 Apr 2008 18:06:36 +0200,    group: microsoft.public.platformsdk.shell        back       


How to find the status of mapped drives   
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: Sun, 06 Apr 2008 18:06:36 +0200   author:   Hermann Schinagl

Re: How to find the status of mapped drives   
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?

-- 
Jim Barry, Microsoft MVP
date: Mon, 7 Apr 2008 13:44:03 +0100   author:   Jim Barry

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

Re: How to find the status of mapped drives   
Hermann Schinagl wrote:
> I have tried, and theoretically it could, but I was
> up till now never able to successfully call SHGetDataFromIDList()
> with SHGDFIL_NETRESOURCE.

I just gave it a try and I was able to get a SHDESCRIPTIONID of SHDID_COMPUTER_NETDRIVE, but SHGDFIL_NETRESOURCE indeed fails. As Michael suggested, you can try using the WNet API.

-- 
Jim Barry, Microsoft MVP
date: Wed, 9 Apr 2008 11:17:22 +0100   author:   Jim Barry

Re: How to find the status of mapped drives   
Michael Phillips, Jr. wrote:
> 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.)

I will try again, but my last tests showed, that it took
ages to complete WnetGetConnection, when the network
drive is in zombie state.

That's why I wanted to ask explorer

	Ciao Hermann
date: Wed, 09 Apr 2008 21:25:06 +0200   author:   Hermann Schinagl

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us