problem retrieving domain name [modified]
-
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 stringlpszSystemInfo = 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
-
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 stringlpszSystemInfo = 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
-
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 stringlpszSystemInfo = 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
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]
-
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 stringlpszSystemInfo = 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
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
-
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
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 stringDWORD 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
-
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 stringDWORD 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
Which version of platform SDK are you using?If not download the latest platform SDK from the microsoft site.
nave [OpenedFileFinder]
-
Which version of platform SDK are you using?If not download the latest platform SDK from the microsoft site.
nave [OpenedFileFinder]
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
-
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
declaration of this file dosent come with the vc 6. You neeed to download the latest platform SDK
nave [OpenedFileFinder]