CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 1999
    Location
    Spain
    Posts
    335

    How can I get the UNC path of a drive ?

    Hi,

    I would like to get the UNC path of one drive for example for:

    F:

    Win on SERVER1-NT-PC

    Or something like that ;-), How can I get this ?
    Thanks, Bye !
    Braulio





  2. #2
    Join Date
    May 1999
    Posts
    29

    Re: How can I get the UNC path of a drive ?

    Hi Braulio!
    The WNetGetUniversalName function takes a drive-based path for a network resource and obtains a data structure that contains a more universal form of the name. Look into the help for more details on how to use it.

    Here is a piece of code which will help get the UNC path given the drive(in this case the drive letter E is given).

    #include "winnetwk.h"

    UNIVERSAL_NAME_INFO UNC;
    DWORD dsize = 500;
    WNetGetUniversalName("E:\\", UNIVERSAL_NAME_INFO_LEVEL,&UNC,(LPDWORD)&dsize);
    AfxMessageBox(UNC.lpUniversalName);

    Do let me know if it works.

    Regards,
    Sukanya Swaminathan
    Software Engineer
    Aditi Technologies
    Blr - 80
    Email : [email protected]


  3. #3
    Join Date
    Jun 1999
    Posts
    5

    Re: How can I get the UNC path of a drive ?

    Hello,

    I tried to use WNetGetUniversalName, compiling works very well but linking failed with
    Test.obj : error LNK2001: unresolved external symbol _WNetGetUniversalNameA@16


    .
    In the online-help I couldn't find any information about the need to add a lib for linking. Can you help me?

    Thomas Wollny


  4. #4
    Join Date
    Apr 1999
    Location
    Alabama, USA
    Posts
    261

    Re: How can I get the UNC path of a drive ?

    mpr.lib is what you should link with.

    Happy Coding


  5. #5
    Join Date
    Jun 1999
    Posts
    5

    Re: How can I get the UNC path of a drive ?

    Thanks John,

    it seems I was blind, I looked 5 times into the Quick Info but didn't see the line "Import Library mpr.lib". Next time I will look better.

    Thomas Wollny


  6. #6
    Guest

    Re: How can I get the UNC path of a drive ?

    Hello Braudio,

    Try this:

    GetComputerName(lpszValue, &dwSize);

    It works for me.



    David Chan


  7. #7
    Guest

    Re: How can I get the UNC path of a drive ?

    I tried this for practice and it works fine, the message box appears with the full name of the selected drive
    however after that when I leave the

  8. #8
    Join Date
    Oct 1999
    Location
    Milwaukee, WI, USA
    Posts
    3

    Re: How can I get the UNC path of a drive ?

    hi,
    i too receiving the same error message during linking. But my requirement is on Win95. the quickinfo says its only supported on WinNT.
    Can you guys help me out.

    Maruthi Chirala

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured