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. Windows User Name and HostName

Windows User Name and HostName

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 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.
  • R Offline
    R Offline
    RadioOpa
    wrote on last edited by
    #1

    How to read Windows User Name and the machine Host name in a VC application ?

    C D T 3 Replies Last reply
    0
    • R RadioOpa

      How to read Windows User Name and the machine Host name in a VC application ?

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      The function NetWkstaUserGetInfo can be called to get the User Name. The function NetWkstaGetInfo can be called to get the computer name. There are security restrictions in place that could cause these calls to fail, though. Chris Meech I am Canadian. [heard in a local bar] When I want privacy, I'll close the bathroom door. [Stan Shannon] BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com] Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]

      1 Reply Last reply
      0
      • R RadioOpa

        How to read Windows User Name and the machine Host name in a VC application ?

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

        RadioOpa wrote:

        How to read...Host name in a VC application ?

        Try gethostname().


        "The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli

        1 Reply Last reply
        0
        • R RadioOpa

          How to read Windows User Name and the machine Host name in a VC application ?

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

          RadioOpa wrote:

          Windows User Name

          GetUserName

          RadioOpa wrote:

          machine Host name

          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

          R 1 Reply Last reply
          0
          • T ThatsAlok

            RadioOpa wrote:

            Windows User Name

            GetUserName

            RadioOpa wrote:

            machine Host name

            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

            R Offline
            R Offline
            RadioOpa
            wrote on last edited by
            #5

            Many Thanks ! I´ve done it this way: DWORD dwLength = MAX_COMPUTERNAME_LENGTH + 1; CString csComputerName; GetComputerName( csComputerName.GetBuffer( 0), &dwLength);

            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