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. problem retrieving domain name [modified]

problem retrieving domain name [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 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.
  • M Offline
    M Offline
    Moonis Ahmed
    wrote on last edited by
    #1

    hi, i am trying to retrieve domain and user name by the following code

    #include "windows.h"

    LPTSTR lpszSystemInfo; // pointer to system information string
    DWORD cchBuff = BUFSIZE; // size of domain name
    TCHAR tchBuffer[bufsize]; // buffer for string

    lpszSystemInfo = tchBuffer;

    // Get machine name
    if( GetComputerName(lpszSystemInfo, &cchBuff) )
    m_machineName = _bstr_t(lpszSystemInfo);

    // Get domain.
    cchBuff = BUFSIZE;
    if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
    m_domain = _bstr_t(lpszSystemInfo);

    // Get user name.

    cchBuff = BUFSIZE;
    if( GetUserName(lpszSystemInfo, &cchBuff) )
    m_osUsername = _bstr_t(lpszSystemInfo);

    This is a part of the code. When i compile it, I get the following error: error C2065: 'GetComputerNameEx' : undeclared identifier error C2065: 'ComputerNameDnsDomain' : undeclared identifier Can anyone help me solve it? Moonis -- modified at 21:39 Sunday 3rd June, 2007

    N A R 3 Replies Last reply
    0
    • M Moonis Ahmed

      hi, i am trying to retrieve domain and user name by the following code

      #include "windows.h"

      LPTSTR lpszSystemInfo; // pointer to system information string
      DWORD cchBuff = BUFSIZE; // size of domain name
      TCHAR tchBuffer[bufsize]; // buffer for string

      lpszSystemInfo = tchBuffer;

      // Get machine name
      if( GetComputerName(lpszSystemInfo, &cchBuff) )
      m_machineName = _bstr_t(lpszSystemInfo);

      // Get domain.
      cchBuff = BUFSIZE;
      if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
      m_domain = _bstr_t(lpszSystemInfo);

      // Get user name.

      cchBuff = BUFSIZE;
      if( GetUserName(lpszSystemInfo, &cchBuff) )
      m_osUsername = _bstr_t(lpszSystemInfo);

      This is a part of the code. When i compile it, I get the following error: error C2065: 'GetComputerNameEx' : undeclared identifier error C2065: 'ComputerNameDnsDomain' : undeclared identifier Can anyone help me solve it? Moonis -- modified at 21:39 Sunday 3rd June, 2007

      A Offline
      A Offline
      Arman S
      wrote on last edited by
      #2

      Please put any code inside < pre>< /pre> tag to view it correctly. Before including you should define _WIN32_WINNT greater than or equal to 0x500;

      #define _WIN32_WINNT 0x0500
      #include <windows.h>

      -- ===== Arman

      M 1 Reply Last reply
      0
      • M Moonis Ahmed

        hi, i am trying to retrieve domain and user name by the following code

        #include "windows.h"

        LPTSTR lpszSystemInfo; // pointer to system information string
        DWORD cchBuff = BUFSIZE; // size of domain name
        TCHAR tchBuffer[bufsize]; // buffer for string

        lpszSystemInfo = tchBuffer;

        // Get machine name
        if( GetComputerName(lpszSystemInfo, &cchBuff) )
        m_machineName = _bstr_t(lpszSystemInfo);

        // Get domain.
        cchBuff = BUFSIZE;
        if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
        m_domain = _bstr_t(lpszSystemInfo);

        // Get user name.

        cchBuff = BUFSIZE;
        if( GetUserName(lpszSystemInfo, &cchBuff) )
        m_osUsername = _bstr_t(lpszSystemInfo);

        This is a part of the code. When i compile it, I get the following error: error C2065: 'GetComputerNameEx' : undeclared identifier error C2065: 'ComputerNameDnsDomain' : undeclared identifier Can anyone help me solve it? Moonis -- modified at 21:39 Sunday 3rd June, 2007

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        You have to define the _WIN32_WINNT version to 0x0500 or greater. for this Take project settings->c++->Preprocessor definition. In that edit box add _WIN32_WINNT=0x0500

        nave [OpenedFileFinder]

        1 Reply Last reply
        0
        • M Moonis Ahmed

          hi, i am trying to retrieve domain and user name by the following code

          #include "windows.h"

          LPTSTR lpszSystemInfo; // pointer to system information string
          DWORD cchBuff = BUFSIZE; // size of domain name
          TCHAR tchBuffer[bufsize]; // buffer for string

          lpszSystemInfo = tchBuffer;

          // Get machine name
          if( GetComputerName(lpszSystemInfo, &cchBuff) )
          m_machineName = _bstr_t(lpszSystemInfo);

          // Get domain.
          cchBuff = BUFSIZE;
          if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
          m_domain = _bstr_t(lpszSystemInfo);

          // Get user name.

          cchBuff = BUFSIZE;
          if( GetUserName(lpszSystemInfo, &cchBuff) )
          m_osUsername = _bstr_t(lpszSystemInfo);

          This is a part of the code. When i compile it, I get the following error: error C2065: 'GetComputerNameEx' : undeclared identifier error C2065: 'ComputerNameDnsDomain' : undeclared identifier Can anyone help me solve it? Moonis -- modified at 21:39 Sunday 3rd June, 2007

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #4

          Hi, In the msdn documentation for GetComputerNameEx it is given "To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 or later" have to confirmed it and it required to include windows.h

          1 Reply Last reply
          0
          • A Arman S

            Please put any code inside < pre>< /pre> tag to view it correctly. Before including you should define _WIN32_WINNT greater than or equal to 0x500;

            #define _WIN32_WINNT 0x0500
            #include <windows.h>

            -- ===== Arman

            M Offline
            M Offline
            Moonis Ahmed
            wrote on last edited by
            #5

            Hi, I did the above settings to enable the macro but the problem still persists.:sigh: My modified code is here:

            #define _WIN32_WINNT 0x0500
            #include "windows.h"
            #include "stdio.h"
            #include "iostream.h"
            #include "tchar.h"

            int main()
            {
            LPTSTR lpszSystemInfo;// pointer to system information string

            DWORD cchBuff=sizeof(lpszSystemInfo);// size of domain name
            
            // Get domain.
            if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
            cout<<"Domain Name is : "< 
            

            I am new to VC++ programming so please point out any other errors if there are.

            Moonis

            N 1 Reply Last reply
            0
            • M Moonis Ahmed

              Hi, I did the above settings to enable the macro but the problem still persists.:sigh: My modified code is here:

              #define _WIN32_WINNT 0x0500
              #include "windows.h"
              #include "stdio.h"
              #include "iostream.h"
              #include "tchar.h"

              int main()
              {
              LPTSTR lpszSystemInfo;// pointer to system information string

              DWORD cchBuff=sizeof(lpszSystemInfo);// size of domain name
              
              // Get domain.
              if (GetComputerNameEx(ComputerNameDnsDomain, lpszSystemInfo, &cchBuff))
              cout<<"Domain Name is : "< 
              

              I am new to VC++ programming so please point out any other errors if there are.

              Moonis

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              Which version of platform SDK are you using?If not download the latest platform SDK from the microsoft site.

              nave [OpenedFileFinder]

              M 1 Reply Last reply
              0
              • N Naveen

                Which version of platform SDK are you using?If not download the latest platform SDK from the microsoft site.

                nave [OpenedFileFinder]

                M Offline
                M Offline
                Moonis Ahmed
                wrote on last edited by
                #7

                Hi, I am using MS Visual C++ 6.0 running on Windows 2000 Server. Is the problem related to the above version that i am running? Moonis

                N 1 Reply Last reply
                0
                • M Moonis Ahmed

                  Hi, I am using MS Visual C++ 6.0 running on Windows 2000 Server. Is the problem related to the above version that i am running? Moonis

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #8

                  declaration of this file dosent come with the vc 6. You neeed to download the latest platform SDK

                  nave [OpenedFileFinder]

                  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