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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get computer name ?

Get computer name ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
28 Posts 8 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.
  • S Offline
    S Offline
    Surivevoli
    wrote on last edited by
    #1

    I have a small question : what function is used to get name of my computer ?

    T K E 3 Replies Last reply
    0
    • S Surivevoli

      I have a small question : what function is used to get name of my computer ?

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

      Surivevoli wrote:

      what function is used to get name of my computer ?

      GetComputerName()...

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

      cheers, Alok Gupta VC Forum Q&A :- I/ IV

      S 2 Replies Last reply
      0
      • T ThatsAlok

        Surivevoli wrote:

        what function is used to get name of my computer ?

        GetComputerName()...

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

        cheers, Alok Gupta VC Forum Q&A :- I/ IV

        S Offline
        S Offline
        Surivevoli
        wrote on last edited by
        #3

        Thank you very much !;)

        1 Reply Last reply
        0
        • S Surivevoli

          I have a small question : what function is used to get name of my computer ?

          K Offline
          K Offline
          kiran janaswamy
          wrote on last edited by
          #4

          hi, use GetComputerName(...) Api or gethostbyname(...) Api. cheers, uday. uday kiran

          S D 2 Replies Last reply
          0
          • S Surivevoli

            I have a small question : what function is used to get name of my computer ?

            E Offline
            E Offline
            Eytukan
            wrote on last edited by
            #5

            You have the answer in your question itself :)


            --[V]--

            [My Current Status]

            S 1 Reply Last reply
            0
            • T ThatsAlok

              Surivevoli wrote:

              what function is used to get name of my computer ?

              GetComputerName()...

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

              cheers, Alok Gupta VC Forum Q&A :- I/ IV

              S Offline
              S Offline
              Surivevoli
              wrote on last edited by
              #6

              but i don't know use parameter in that funtion : GetComputerName(...); could you help me ???

              T 1 Reply Last reply
              0
              • K kiran janaswamy

                hi, use GetComputerName(...) Api or gethostbyname(...) Api. cheers, uday. uday kiran

                S Offline
                S Offline
                Surivevoli
                wrote on last edited by
                #7

                but i don't know use parameter in that funtion : GetComputerName(...); could you help me ???

                1 Reply Last reply
                0
                • E Eytukan

                  You have the answer in your question itself :)


                  --[V]--

                  [My Current Status]

                  S Offline
                  S Offline
                  Surivevoli
                  wrote on last edited by
                  #8

                  but i don't know use parameter in that funtion : GetComputerName(...); could you help me ???

                  E K 2 Replies Last reply
                  0
                  • S Surivevoli

                    but i don't know use parameter in that funtion : GetComputerName(...); could you help me ???

                    K Offline
                    K Offline
                    kiran janaswamy
                    wrote on last edited by
                    #9

                    hi , This is the Snippet of Code //=========================================================== #define INFO_BUFFER_SIZE 32767 TCHAR infoBuf[INFO_BUFFER_SIZE]; DWORD bufCharCount = INFO_BUFFER_SIZE; GetComputerName( infoBuf, &bufCharCount); //========================================================== the infoBuf contains the Computer Name. good luck. cheers. uday kiran

                    S 2 Replies Last reply
                    0
                    • S Surivevoli

                      but i don't know use parameter in that funtion : GetComputerName(...); could you help me ???

                      E Offline
                      E Offline
                      Eytukan
                      wrote on last edited by
                      #10

                      #define INFO_BUFFER_SIZE 32767 LPSTR computerName = new char(50); dw = INFO_BUFFER_SIZE; GetComputerName(computerName,&dw);


                      --[V]--

                      [My Current Status]

                      R 1 Reply Last reply
                      0
                      • K kiran janaswamy

                        hi , This is the Snippet of Code //=========================================================== #define INFO_BUFFER_SIZE 32767 TCHAR infoBuf[INFO_BUFFER_SIZE]; DWORD bufCharCount = INFO_BUFFER_SIZE; GetComputerName( infoBuf, &bufCharCount); //========================================================== the infoBuf contains the Computer Name. good luck. cheers. uday kiran

                        S Offline
                        S Offline
                        Surivevoli
                        wrote on last edited by
                        #11

                        Thank you very and very much !!!

                        1 Reply Last reply
                        0
                        • K kiran janaswamy

                          hi, use GetComputerName(...) Api or gethostbyname(...) Api. cheers, uday. uday kiran

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

                          kiran janaswamy wrote:

                          use...gethostbyname(...) Api.

                          This function does not retrieve the host name. It uses the host name to retrieve host information such as IP address.


                          "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                          "We will be known forever by the tracks we leave." - Native American Proverb

                          K S 2 Replies Last reply
                          0
                          • D David Crow

                            kiran janaswamy wrote:

                            use...gethostbyname(...) Api.

                            This function does not retrieve the host name. It uses the host name to retrieve host information such as IP address.


                            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                            "We will be known forever by the tracks we leave." - Native American Proverb

                            K Offline
                            K Offline
                            kiran janaswamy
                            wrote on last edited by
                            #13

                            hi, sorry it is gethostname(...) Api. cheers, uday. uday kiran

                            1 Reply Last reply
                            0
                            • S Surivevoli

                              but i don't know use parameter in that funtion : GetComputerName(...); could you help me ???

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

                              Surivevoli wrote:

                              GetComputerName(...);

                              TCHAR szCompName[MAX_PATH]; GetComputerName(szCompName,MAX_PATH);

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

                              cheers, Alok Gupta VC Forum Q&A :- I/ IV

                              H 1 Reply Last reply
                              0
                              • E Eytukan

                                #define INFO_BUFFER_SIZE 32767 LPSTR computerName = new char(50); dw = INFO_BUFFER_SIZE; GetComputerName(computerName,&dw);


                                --[V]--

                                [My Current Status]

                                R Offline
                                R Offline
                                Ryan Binns
                                wrote on last edited by
                                #15

                                VuNic wrote:

                                #define INFO_BUFFER_SIZE 32767

                                What's wrong with using the system-defined MAX_COMPUTERNAME_LENGTH?

                                Ryan

                                "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                                S 1 Reply Last reply
                                0
                                • T ThatsAlok

                                  Surivevoli wrote:

                                  GetComputerName(...);

                                  TCHAR szCompName[MAX_PATH]; GetComputerName(szCompName,MAX_PATH);

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

                                  cheers, Alok Gupta VC Forum Q&A :- I/ IV

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

                                  Hi ThatsAlok, I thnik he can read from registry

                                  S S T 3 Replies Last reply
                                  0
                                  • H Hamid Taebi

                                    Hi ThatsAlok, I thnik he can read from registry

                                    S Offline
                                    S Offline
                                    Surivevoli
                                    wrote on last edited by
                                    #17

                                    could you tell me do that ?

                                    H 1 Reply Last reply
                                    0
                                    • D David Crow

                                      kiran janaswamy wrote:

                                      use...gethostbyname(...) Api.

                                      This function does not retrieve the host name. It uses the host name to retrieve host information such as IP address.


                                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                                      "We will be known forever by the tracks we leave." - Native American Proverb

                                      S Offline
                                      S Offline
                                      Surivevoli
                                      wrote on last edited by
                                      #18

                                      Could you tell me : How to get my IP address ??? What's happened if my computer don't connect to the Internet or LAN, or i don't install IIS ??? And: If i connect over LAN, how to get other Computer name if i know its IP and how to get other computer's IP if i know its name ?

                                      D 1 Reply Last reply
                                      0
                                      • K kiran janaswamy

                                        hi , This is the Snippet of Code //=========================================================== #define INFO_BUFFER_SIZE 32767 TCHAR infoBuf[INFO_BUFFER_SIZE]; DWORD bufCharCount = INFO_BUFFER_SIZE; GetComputerName( infoBuf, &bufCharCount); //========================================================== the infoBuf contains the Computer Name. good luck. cheers. uday kiran

                                        S Offline
                                        S Offline
                                        Surivevoli
                                        wrote on last edited by
                                        #19

                                        Could you tell me : How to get my IP address ??? What's happened if my computer don't connect to the Internet or LAN, or i don't install IIS ??? And: If i connect over LAN, how to get other Computer name if i know its IP and how to get other computer's IP if i know its name ?

                                        1 Reply Last reply
                                        0
                                        • R Ryan Binns

                                          VuNic wrote:

                                          #define INFO_BUFFER_SIZE 32767

                                          What's wrong with using the system-defined MAX_COMPUTERNAME_LENGTH?

                                          Ryan

                                          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                                          S Offline
                                          S Offline
                                          Surivevoli
                                          wrote on last edited by
                                          #20

                                          what's MAX_COMPUTERNAME_LENGTH ? what is its value ?

                                          D 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