Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get the machine name of the mapped drive C++

Get the machine name of the mapped drive C++

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++sysadminquestion
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raesa
    wrote on last edited by
    #1

    Hi..... I have a small problem in getting the hostname of the mapped drive. I have mapped a shared folder of a machine in network on my system. I have to get the name of the machine from the mapped drive. I was not able to find any proper function for that. Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out? Please do help me out. Thnx in advance...

    D I H 3 Replies Last reply
    0
    • R raesa

      Hi..... I have a small problem in getting the hostname of the mapped drive. I have mapped a shared folder of a machine in network on my system. I have to get the name of the machine from the mapped drive. I was not able to find any proper function for that. Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out? Please do help me out. Thnx in advance...

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      raesa wrote:

      Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?

      Have you tried WNetGetConnection()?

      "Love people and use things, not love things and use people." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      I R 2 Replies Last reply
      0
      • D David Crow

        raesa wrote:

        Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?

        Have you tried WNetGetConnection()?

        "Love people and use things, not love things and use people." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        oops

        Codeproject MVP for C++, I can't believe it's for my lounge posts...

        1 Reply Last reply
        0
        • R raesa

          Hi..... I have a small problem in getting the hostname of the mapped drive. I have mapped a shared folder of a machine in network on my system. I have to get the name of the machine from the mapped drive. I was not able to find any proper function for that. Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out? Please do help me out. Thnx in advance...

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          I did some digging, and the following code worked for me:

          TCHAR szBuf \[MAX\_PATH\];
          DWORD dwSize = MAX\_PATH;
          DWORD dw = WNetGetConnection (\_T("p:"), szBuf, &dwSize);
          

          It gave me "\\myserveraddress\sharename" in szBuf. Iain.

          Codeproject MVP for C++, I can't believe it's for my lounge posts...

          1 Reply Last reply
          0
          • R raesa

            Hi..... I have a small problem in getting the hostname of the mapped drive. I have mapped a shared folder of a machine in network on my system. I have to get the name of the machine from the mapped drive. I was not able to find any proper function for that. Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out? Please do help me out. Thnx in advance...

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            [Message Deleted]

            I 1 Reply Last reply
            0
            • H Hamid Taebi

              [Message Deleted]

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #6

              That was one of the first results in google, but it's using .net namespace functionality, and mapping drives. So almost the exact opposite of what he needs. Phew, regained my sense of superiority after replying to the wrong person earlier! Iain.

              Codeproject MVP for C++, I can't believe it's for my lounge posts...

              D H 2 Replies Last reply
              0
              • I Iain Clarke Warrior Programmer

                That was one of the first results in google, but it's using .net namespace functionality, and mapping drives. So almost the exact opposite of what he needs. Phew, regained my sense of superiority after replying to the wrong person earlier! Iain.

                Codeproject MVP for C++, I can't believe it's for my lounge posts...

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Iain Clarke wrote:

                Phew, regained my sense of superiority after replying to the wrong person earlier!

                You can still delete that post and hardly anyone would know.

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                1 Reply Last reply
                0
                • I Iain Clarke Warrior Programmer

                  That was one of the first results in google, but it's using .net namespace functionality, and mapping drives. So almost the exact opposite of what he needs. Phew, regained my sense of superiority after replying to the wrong person earlier! Iain.

                  Codeproject MVP for C++, I can't believe it's for my lounge posts...

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  Yeah I didnt see .net I delete previous post. Now I changed title of my reply.:-D

                  Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                  I 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    Yeah I didnt see .net I delete previous post. Now I changed title of my reply.:-D

                    Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

                    I Offline
                    I Offline
                    Iain Clarke Warrior Programmer
                    wrote on last edited by
                    #9

                    Hamid. wrote:

                    I delete previous post.

                    No, don't join them! :(( Iain.

                    Codeproject MVP for C++, I can't believe it's for my lounge posts...

                    R 1 Reply Last reply
                    0
                    • I Iain Clarke Warrior Programmer

                      Hamid. wrote:

                      I delete previous post.

                      No, don't join them! :(( Iain.

                      Codeproject MVP for C++, I can't believe it's for my lounge posts...

                      R Offline
                      R Offline
                      Rajesh R Subramanian
                      wrote on last edited by
                      #10

                      Iain Clarke wrote:

                      Codeproject MVP for C++, I can't believe it's for my lounge posts...

                      But I may have a superb reason to defy your arrogant assumptions.

                      It is a crappy thing, but it's life -^ Carlo Pallini

                      I 1 Reply Last reply
                      0
                      • R Rajesh R Subramanian

                        Iain Clarke wrote:

                        Codeproject MVP for C++, I can't believe it's for my lounge posts...

                        But I may have a superb reason to defy your arrogant assumptions.

                        It is a crappy thing, but it's life -^ Carlo Pallini

                        I Offline
                        I Offline
                        Iain Clarke Warrior Programmer
                        wrote on last edited by
                        #11

                        Infamy, infamy, they've all got it in fo' me! Iain.

                        Codeproject MVP for C++, I can't believe it's for my lounge posts...

                        1 Reply Last reply
                        0
                        • D David Crow

                          raesa wrote:

                          Please do let me know if there is some function or some way to do it, because in my program i have to get the name of the machine.Is there a way out?

                          Have you tried WNetGetConnection()?

                          "Love people and use things, not love things and use people." - Unknown

                          "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                          R Offline
                          R Offline
                          raesa
                          wrote on last edited by
                          #12

                          Thnks alot for the help.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups