Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to convert from UNC notation to Drive letter? Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
15-Sep-02
Category
Files Operation
Language
Delphi All Versions
Views
87
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

Convert from UNC notation to Drive letter?

Answer:

The function ExpandUNCFileName function converts a mapped path/file to UNC, but how 
can this process be reversed?

There is no simple function that would do the trick, you have to go through all 
existing 'remote' drives, look at their UNC name and compare them with the one you 
are interested in: 


1   program P;
2   
3   procedure TForm1.Button1Click(Sender: TObject);
4   const
5     YOURUNCFILENAME = '\\ISS\VOL1\ISS\SHARE\';
6   var
7     Drive: Char;
8     Drlist: TStringList;
9     Filist: TStringList;
10    I: integer;
11  begin
12    Drlist := TStringList.Create;
13    Filist := TStringList.Create;
14    for Drive := 'a' to 'z' do
15      case GetDriveType(PChar(Drive + ':\')) of
16        DRIVE_REMOTE:
17          begin
18            Filist.Add(expanduncfilename(Drive + ':\'));
19            Drlist.Add(Drive)
20          end
21      end;
22    {......}
23    I := Filist.indexof(YOURUNCFILENAME);
24    if I > -1 then
25      ShowMessage(YOURUNCFILENAME + 'Mapped to drive ' + Drlist[I]);
26  
27    Drlist.Free;
28    Filist.Free
29  end;
30  
31  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC