Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Map Drive to UNC Pathname 1

Status
Not open for further replies.

Chris16

Programmer
Oct 28, 2009
8
GB
Hi
I need to convert a mapped drive path (eg K:\Projects\ABC) to a UNC path name (like \\Fe_Techuser\User\Projects\ABC)
in a pc based fortran program. I am currently using Compaq visual fortran 6.6. If its easier to get the mapped drive from a UNC Path that would be fine.
Thanks.
Chris16
 
You need an OS call to find out what K has been mapped to. Problem is that it could be a network mapped drive or a substituted drive so you have two separate lookups.

For instance, in the cmd prompt, the user could type

subst k: \\fe_techuser\user

If you typed subst, you'd get
K:\: => UNC\fe_techuser\user

Alternatively you could use a networked drive. This is similar to what windows explorer does.

new use k: \\fe_techuser\user

but you'll need net use to find out what the unc path is. Do you know how you'll be doing the mapping and whether it will be the same every time? Who is setting up the mapping?
 
Thanks for the reply. Assume that it's a network mapped drive not a substituted drive. My ICT department do the mappings. I guessed I'd need to make an OS call but I have no idea of the syntax. A code example of this is what I'm really after. Thanks.
 
Something like this
Code:
    program netusage

    implicit none
    integer, parameter:: netuse = 20
    character*80:: line
    call system ("net use > netuse.txt")
    open (netuse, file='netuse.txt', status='old')
100 continue
       read (netuse, '(A)', end=200) line
       if (line(1:2) .eq. 'OK') then
          print *, line(14:16), ' = ', line(24:48)
       end if
       goto 100
200 continue
    close (netuse)
    end program netusage
Later versions of CVF do not need any additional libraries. Earlier versions will need libpepcf90xx.lib where xx is MT or MD or empty. You will also need the corresponding DLL on your path.
 
Thanks that did exatcly what I wanted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top