Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1999 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. compinfo.cpp
  7. Computer info class plus helper functions
  8. FILE HISTORY:
  9. */
  10. #define IP_ADDDRESS_LENGTH_MAX 16
  11. typedef enum COMPUTER_INFO_TYPE
  12. {
  13. COMPUTER_INFO_TYPE_IP,
  14. COMPUTER_INFO_TYPE_DNS,
  15. COMPUTER_INFO_TYPE_NB
  16. };
  17. class CIpInfo
  18. {
  19. public:
  20. DWORD dwIp;
  21. CString strFqdn;
  22. };
  23. typedef CArray<CIpInfo, CIpInfo &> CIpInfoArrayBase;
  24. class CIpInfoArray : public CIpInfoArrayBase
  25. {
  26. public:
  27. BOOL FIsInList(DWORD dwIp);
  28. };
  29. class CComputerInfo
  30. {
  31. public:
  32. CComputerInfo(LPCTSTR pszNameOrIp);
  33. ~CComputerInfo();
  34. HRESULT GetIp(DWORD * pdwIp, int nIndex = 0);
  35. HRESULT GetIpStr(CString & strIp, int nIndex = 0);
  36. HRESULT GetHostName(CString & strHostName);
  37. HRESULT GetFqdn(CString & strFqdn, int nIndex = 0);
  38. int GetCount();
  39. HRESULT GetDomain(CString & strDomain);
  40. COMPUTER_INFO_TYPE GetInputType();
  41. HRESULT IsLocalMachine(BOOL * pfIsLocal);
  42. HRESULT InitializeData();
  43. void Reset();
  44. // internal functions
  45. protected:
  46. HRESULT GetHostInfo(DWORD dhipa);
  47. HRESULT GetHostAddressFQDN(LPCTSTR pszHostName, CString * pstrFQDN, DWORD * pdhipa);
  48. DWORD addrFromHostent(const HOSTENT * pHostent, INT index = 0);
  49. HRESULT GetHostAddress(LPCTSTR pszHostName, DWORD * pdhipa);
  50. HRESULT GetLocalHostAddress(DWORD * pdhipa);
  51. HRESULT GetLocalHostName(CString * pstrName);
  52. private:
  53. CString m_strNameOrIp;
  54. CString m_strHostname;
  55. int m_nIndex;
  56. CIpInfoArray m_arrayIps;
  57. };