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. how to enume hosts of my LAN

how to enume hosts of my LAN

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
13 Posts 4 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.
  • Y Offline
    Y Offline
    yanping wang
    wrote on last edited by
    #1

    I need to enume the hosts of my LAN. I have tried to use WNet functions, but with little success. Can anyone provide me a way to achieve this?? thank you very much.

    2 D 2 Replies Last reply
    0
    • Y yanping wang

      I need to enume the hosts of my LAN. I have tried to use WNet functions, but with little success. Can anyone provide me a way to achieve this?? thank you very much.

      2 Offline
      2 Offline
      224917
      wrote on last edited by
      #2

      Hope this article helps :http://www.codeproject.com/internet/xLANInfo.asp[^]


      suhredayan
      There is no spoon.

      Y 1 Reply Last reply
      0
      • 2 224917

        Hope this article helps :http://www.codeproject.com/internet/xLANInfo.asp[^]


        suhredayan
        There is no spoon.

        Y Offline
        Y Offline
        yanping wang
        wrote on last edited by
        #3

        xLANInfo does not work in my Computer at all. it use the WNet functions. can you provide me another method. thank you very much

        T 1 Reply Last reply
        0
        • Y yanping wang

          xLANInfo does not work in my Computer at all. it use the WNet functions. can you provide me another method. thank you very much

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          yanping wang wrote: can you provide me another method. try this :- http://www.codeproject.com/w2k/sumeetnetserv.asp[^]

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta

          2 Y 2 Replies Last reply
          0
          • T ThatsAlok

            yanping wang wrote: can you provide me another method. try this :- http://www.codeproject.com/w2k/sumeetnetserv.asp[^]

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            2 Offline
            2 Offline
            224917
            wrote on last edited by
            #5

            I guess its a 9x machine over there !


            suhredayan
            There is no spoon.

            T 1 Reply Last reply
            0
            • T ThatsAlok

              yanping wang wrote: can you provide me another method. try this :- http://www.codeproject.com/w2k/sumeetnetserv.asp[^]

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta

              Y Offline
              Y Offline
              yanping wang
              wrote on last edited by
              #6

              Thank you . I download the demo, but it does not work too. we all use Windows SP2 system. Now i have found a way to achieve my purpose. i send ARP request to all Local ip addresses. the ones who reply my request exit in my LAN.

              1 Reply Last reply
              0
              • 2 224917

                I guess its a 9x machine over there !


                suhredayan
                There is no spoon.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                suhredayan® wrote: its a 9x machine over there ! I don't know? :). But I believe he is facing problem due to XP Service Pack 2. I have no knowledge about it :sigh: do u?

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta

                1 Reply Last reply
                0
                • Y yanping wang

                  I need to enume the hosts of my LAN. I have tried to use WNet functions, but with little success. Can anyone provide me a way to achieve this?? thank you very much.

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

                  yanping wang wrote: I have tried to use WNet functions, but with little success. Show us the code that is not working. What does it produce?


                  "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                  Y 3 Replies Last reply
                  0
                  • D David Crow

                    yanping wang wrote: I have tried to use WNet functions, but with little success. Show us the code that is not working. What does it produce?


                    "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                    Y Offline
                    Y Offline
                    yanping wang
                    wrote on last edited by
                    #9

                    Thank you for your reply. The problem is that not every hosts have the ablity to enume hosts in LAN by using WNet functions. only the one which is a domain administrator have the ability. so i think the WNet functions do not fit me.

                    1 Reply Last reply
                    0
                    • D David Crow

                      yanping wang wrote: I have tried to use WNet functions, but with little success. Show us the code that is not working. What does it produce?


                      "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                      Y Offline
                      Y Offline
                      yanping wang
                      wrote on last edited by
                      #10

                      now I have succefully enumed hosts of my LAN by sending ARP request. but this require to install Ourself protocol driver to send ARP requests(SendARP does not fit). It worked very good.

                      1 Reply Last reply
                      0
                      • D David Crow

                        yanping wang wrote: I have tried to use WNet functions, but with little success. Show us the code that is not working. What does it produce?


                        "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                        Y Offline
                        Y Offline
                        yanping wang
                        wrote on last edited by
                        #11

                        my demo code is here(using WNet). it can not enume hosts: #include "../common/initsock.h" //#include "Ws2tcpip.h" #include #include #include #include #include CInitSock theSock; // to call WSAStartup function using namespace std; #include "Iphlpapi.h" #pragma comment(lib, "Iphlpapi.lib") #pragma comment(lib, "Mpr.lib") BOOL EnumRes(); void main() { EnumRes(); } BOOL EnumRes() { HANDLE hEnum; DWORD dw = ::WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, NULL, &hEnum); if(dw != NO_ERROR) { printf(" OpenEnum failed \n"); } DWORD cCount = -1; u_char lpBuffer[1024*16]; DWORD cBufferSize = 1024*16; do { dw = ::WNetEnumResource(hEnum, &cCount, lpBuffer, &cBufferSize); NETRESOURCE *pRes = (NETRESOURCE *)lpBuffer; if(dw == NO_ERROR) { for(int i=0; i

                        D 1 Reply Last reply
                        0
                        • Y yanping wang

                          my demo code is here(using WNet). it can not enume hosts: #include "../common/initsock.h" //#include "Ws2tcpip.h" #include #include #include #include #include CInitSock theSock; // to call WSAStartup function using namespace std; #include "Iphlpapi.h" #pragma comment(lib, "Iphlpapi.lib") #pragma comment(lib, "Mpr.lib") BOOL EnumRes(); void main() { EnumRes(); } BOOL EnumRes() { HANDLE hEnum; DWORD dw = ::WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, NULL, &hEnum); if(dw != NO_ERROR) { printf(" OpenEnum failed \n"); } DWORD cCount = -1; u_char lpBuffer[1024*16]; DWORD cBufferSize = 1024*16; do { dw = ::WNetEnumResource(hEnum, &cCount, lpBuffer, &cBufferSize); NETRESOURCE *pRes = (NETRESOURCE *)lpBuffer; if(dw == NO_ERROR) { for(int i=0; i

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

                          yanping wang wrote: it can not enume hosts: Why? Are you getting a runtime error? If so, what? yanping wang wrote: if(pRes[i].dwUsage == RESOURCEUSAGE_CONTAINER) You may want to change this to:

                          if ((pRes[i].dwUsage & RESOURCEUSAGE_CONTAINER) == RESOURCEUSAGE_CONTAINER)


                          "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                          Y 1 Reply Last reply
                          0
                          • D David Crow

                            yanping wang wrote: it can not enume hosts: Why? Are you getting a runtime error? If so, what? yanping wang wrote: if(pRes[i].dwUsage == RESOURCEUSAGE_CONTAINER) You may want to change this to:

                            if ((pRes[i].dwUsage & RESOURCEUSAGE_CONTAINER) == RESOURCEUSAGE_CONTAINER)


                            "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

                            Y Offline
                            Y Offline
                            yanping wang
                            wrote on last edited by
                            #13

                            thank you. the change you made is right. thank you very much

                            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