get drive letter from unc

Hi,

How can I get the drive letter given the UNC name of a mapped drive in
Windows XP?

Whenever I filter a mapped drive in Windows XP using a file filter, it
always return me its UNC name.
How can I get its equivalent drive letter?

Hope you can help.

Thank You!

cheers,
vincent


Fast. Clear. Easy. The new face of MSN Search. http://search.msn.com.sg/

The better question is: why would you?
And I didn’t notice it returns UNC only (though I last did file name parsing
year+ ago), but if the UNC IS mapped to a drive letter AND the user is accessing the
files via the drive letter then it returns the drive letter AND the UNC (something
like ;Z:0\Server\Share\FilePath)

vincent gambit wrote:

Hi,

How can I get the drive letter given the UNC name of a mapped drive in
Windows XP?

Whenever I filter a mapped drive in Windows XP using a file filter, it
always return me its UNC name.
How can I get its equivalent drive letter?

Hope you can help.

Thank You!

cheers,
vincent


Fast. Clear. Easy. The new face of MSN Search. http://search.msn.com.sg/


Questions? First check the IFS FAQ at https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.

Hi,

thanks for your reply.
you are right that the drive letter will show in the UNC
However, if you try using Windows Media 9 and play a video from the mapped
drive, you will notice that it seemed that Windows Media 9 resolve the
mapped drive to a UNC programmatically without the drive letter. Maybe
Windows Media 9 use WNetGetConnection?
Not sure how they resolve mapped drive.

Hope you can help.

Thank You!

cheers,
vincent

From: Dejan Maksimovic
>Reply-To: “Windows File Systems Devs Interest List”
>To: “Windows File Systems Devs Interest List”
>Subject: Re: [ntfsd] get drive letter from unc
>Date: Sat, 14 Aug 2004 07:00:39 +0200
>
>
> The better question is: why would you?
> And I didn’t notice it returns UNC only (though I last did file name
>parsing
>year+ ago), but if the UNC IS mapped to a drive letter AND the user is
>accessing the
>files via the drive letter then it returns the drive letter AND the UNC
>(something
>like ;Z:0\Server\Share\FilePath)
>
>vincent gambit wrote:
>
> > Hi,
> >
> > How can I get the drive letter given the UNC name of a mapped drive in
> > Windows XP?
> >
> > Whenever I filter a mapped drive in Windows XP using a file filter, it
> > always return me its UNC name.
> > How can I get its equivalent drive letter?
> >
> > Hope you can help.
> >
> > Thank You!
> >
> > cheers,
> > vincent
> >
> >
> > Fast. Clear. Easy. The new face of MSN Search. http://search.msn.com.sg/
> >
> > —
> > Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@alfasp.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>–
>Kind regards, Dejan M. MVP for DDK
>http://www.alfasp.com E-mail: xxxxx@alfasp.com
>Alfa Transparent File Encryptor - Transparent file encryption services.
>Alfa File Protector - File protection and hiding library for Win32
>developers.
>Alfa File Monitor - File monitoring library for Win32 developers.
>
>
>
>—
>Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com


Find it on the web with MSN Search. http://search.msn.com.sg/

I don’t see a point … if they access it via UNC anyway, why do you need the
drive letter?
As a last resort keep a cache helped by a user mode service that lists current
mapped drive letters.

vincent gambit wrote:

Hi,

thanks for your reply.
you are right that the drive letter will show in the UNC
However, if you try using Windows Media 9 and play a video from the mapped
drive, you will notice that it seemed that Windows Media 9 resolve the
mapped drive to a UNC programmatically without the drive letter. Maybe
Windows Media 9 use WNetGetConnection?
Not sure how they resolve mapped drive.


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.

Hi,

thanks for you reply.
because I am filtering mapped drives and my driver only filter certain
mapped drive letter.
for example i only wan to filter G: drive (mapped drive) but not other
mapped drives.
So when Windows Media 9 play a file from G drive, my filter driver will not
know that it is playing a file from G drive since what I get is UNC.

And I dont want to have another user mode application or service.

So there is no way I can lookup the drive letter from the UNC?
Though I know I can do it vice versa.

Hope you can help.

Thank You!

cheers.
vincent

From: Dejan Maksimovic
>Reply-To: “Windows File Systems Devs Interest List”
>To: “Windows File Systems Devs Interest List”
>Subject: Re: [ntfsd] get drive letter from unc
>Date: Mon, 16 Aug 2004 14:54:40 +0200
>
>
> I don’t see a point … if they access it via UNC anyway, why do you
>need the
>drive letter?
> As a last resort keep a cache helped by a user mode service that lists
>current
>mapped drive letters.
>
>vincent gambit wrote:
>
> > Hi,
> >
> > thanks for your reply.
> > you are right that the drive letter will show in the UNC
> > However, if you try using Windows Media 9 and play a video from the
>mapped
> > drive, you will notice that it seemed that Windows Media 9 resolve the
> > mapped drive to a UNC programmatically without the drive letter. Maybe
> > Windows Media 9 use WNetGetConnection?
> > Not sure how they resolve mapped drive.
>
>–
>Kind regards, Dejan M. MVP for DDK
>http://www.alfasp.com E-mail: xxxxx@alfasp.com
>Alfa Transparent File Encryptor - Transparent file encryption services.
>Alfa File Protector - File protection and hiding library for Win32
>developers.
>Alfa File Monitor - File monitoring library for Win32 developers.
>
>
>
>—
>Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

_________________________________________________________________
Find it on the web with MSN Search. http://search.msn.com.sg/

I don’t know if it’s possible in kernel mode, but since noone replied by now I
reckon it’s not.
I think you will run into a lot of pitfalls, aside from WMP, in this approach
though. You are trying to filter a higher level of abstraction at a lower level.

And I dont want to have another user mode application or service.
So there is no way I can lookup the drive letter from the UNC?
Though I know I can do it vice versa.


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.

The mechanism you are using is fundamentally flawed. You can certainly
read the prefix from the object manager name space (via the symbolic
link) what you just said you are trying to achieve WILL NOT WORK with
drive letters.

Suppose I have a server machine (call it ‘server’) and on one of its
drives I have two subdirectories: ‘foo’ and ‘bar’. I then create two
shares, one called ‘fred’ and the other ‘bob’. Let’s say the drive
letter on this machine is F.

On a different machine (where your filter is running) I create a drive
letter mapping to ‘foo’ - let’s call that “Y:”. This is the drive now
specified for filtering.

Media Player uses “browse network neighborhood” and I specify
“\server\fred\sample.mpg”. You correctly translate this to “Y:” and
happily filter the request. Now, I send you an e-mail that includes a
link “\server\F$\foo\sample.mpg”. You double click on this, Media
player opens up the link and begins playing the file. You look at the
name, note that it does not start with “\server\fred” and thus conclude
this is a different drive letter. THIS IS THE SAME FILE.

The problem is that shares are logical names and like most logical
naming schemes suffers from aliasing problems. I generally suggest that
filtering be done exactly the OPPOSITE way to what you are trying to do
(that is, use the UNC name) but I also warn people that this still
suffers from aliasing problems - for which there are no trivial
solutions. If you have a filter on the server system and the client
system, you can solve this problem by communicating between the two of
them because then you can enforce a specific (canonical) name structure
by using information on the structure of the server file system.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

Looking forward to seeing you at the Next OSR File Systems Class October
18, 2004 in Silicon Valley!

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of vincent gambit
Sent: Tuesday, August 17, 2004 10:56 AM
To: ntfsd redirect
Subject: Re: [ntfsd] get drive letter from unc

Hi,

thanks for you reply.
because I am filtering mapped drives and my driver only filter certain
mapped drive letter.
for example i only wan to filter G: drive (mapped drive) but not other
mapped drives.
So when Windows Media 9 play a file from G drive, my filter driver will
not
know that it is playing a file from G drive since what I get is UNC.

And I dont want to have another user mode application or service.

So there is no way I can lookup the drive letter from the UNC?
Though I know I can do it vice versa.

Hope you can help.

Thank You!

cheers.
vincent

From: Dejan Maksimovic
>Reply-To: “Windows File Systems Devs Interest List”

>To: “Windows File Systems Devs Interest List”
>Subject: Re: [ntfsd] get drive letter from unc
>Date: Mon, 16 Aug 2004 14:54:40 +0200
>
>
> I don’t see a point … if they access it via UNC anyway, why do
you
>need the
>drive letter?
> As a last resort keep a cache helped by a user mode service that
lists
>current
>mapped drive letters.
>
>vincent gambit wrote:
>
> > Hi,
> >
> > thanks for your reply.
> > you are right that the drive letter will show in the UNC
> > However, if you try using Windows Media 9 and play a video from the
>mapped
> > drive, you will notice that it seemed that Windows Media 9 resolve
the
> > mapped drive to a UNC programmatically without the drive letter.
Maybe
> > Windows Media 9 use WNetGetConnection?
> > Not sure how they resolve mapped drive.
>
>–
>Kind regards, Dejan M. MVP for DDK
>http://www.alfasp.com E-mail: xxxxx@alfasp.com
>Alfa Transparent File Encryptor - Transparent file encryption services.
>Alfa File Protector - File protection and hiding library for Win32
>developers.
>Alfa File Monitor - File monitoring library for Win32 developers.
>
>
>
>—
>Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@hotmail.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

_________________________________________________________________
Find it on the web with MSN Search. http://search.msn.com.sg/


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> I think you will run into a lot of pitfalls, aside from WMP, in this
approach

though. You are trying to filter a higher level of abstraction at a lower
level.

> And I dont want to have another user mode application or service.
> So there is no way I can lookup the drive letter from the UNC?

WNetxxx APIs is a way to go.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com