OSDN Git Service

Send Attachment successfully
[tortoisegit/TortoiseGitJp.git] / src / Utils / NetAdapterInfo.h
1 // OneNetAdapterInfo.h: interface for the COneNetAdapterInfo class.\r
2 //\r
3 //////////////////////////////////////////////////////////////////////\r
4 \r
5 #if !defined(AFX_OneNetAdapterInfo_H__A899410F_5CFF_4958_80C4_D1AC693F62E3__INCLUDED_)\r
6 #define AFX_OneNetAdapterInfo_H__A899410F_5CFF_4958_80C4_D1AC693F62E3__INCLUDED_\r
7 \r
8 #if _MSC_VER > 1000\r
9 #pragma once\r
10 #endif // _MSC_VER > 1000\r
11 \r
12 /*\r
13                 ËµÃ÷\r
14         »ñÈ¡Íø¿¨ÐÅÏ¢£¬°üÀ¨IPµØÖ·¡¢DNS¡¢Íø¹Ø¡¢ÊÇ·ñΪ¶¯Ì¬IP¡¢DHCPµÈ£¬¸ÃÀ಻ÓöÁȡע²á±í¼´¿É»ñÈ¡×îеÄÍø¿¨ÐÅÏ¢\r
15 ÁíÍ⻹¿ÉÒÔÊÍ·ÅÍø¿¨µØÖ·²¢ÖØÐÂˢеØÖ·\r
16 */\r
17 \r
18 #include <winsock2.h>\r
19 #include <iphlpapi.h>\r
20 #include <Afxtempl.h>\r
21 \r
22 typedef struct _IPINFO\r
23 {\r
24         CString csIP;\r
25         CString csSubnet;\r
26 } t_IPINFO;\r
27 typedef CArray<t_IPINFO,t_IPINFO&> t_Ary_IPINFO;\r
28 \r
29 typedef DWORD ( __stdcall *Func_OperateIP)( PIP_ADAPTER_INDEX_MAP AdapterInfo );\r
30 CString MacAddress2String ( int nPhysicalAddressLength, BYTE *pPhysicalAddress );\r
31 \r
32 class COneNetAdapterInfo\r
33 {\r
34 public:\r
35         COneNetAdapterInfo ( IP_ADAPTER_INFO *pAdptInfo );\r
36         virtual ~COneNetAdapterInfo();\r
37         CString Get_Name() { return m_csName; }\r
38         CString Get_Desc() { return m_csDesc; }\r
39         BOOL ReleaseIP();\r
40         BOOL RenewIP();\r
41         CString GetAdapterTypeString ();\r
42 \r
43         time_t Get_LeaseObtained() const;\r
44         time_t Get_LeaseExpired() const;\r
45         int     Get_IPCount() const;\r
46         int     Get_DNSCount() const;\r
47         CString Get_CurrentIP() const;\r
48         BOOL Is_DHCP_Used() const;\r
49         CString Get_DHCPAddr() const;\r
50         BOOL Is_Wins_Used() const;\r
51         CString Get_PrimaryWinsServer() const;\r
52         CString Get_SecondaryWinsServer() const;\r
53         int     Get_GatewayCount() const;\r
54         DWORD Get_AdapterIndex() const;\r
55         UINT Get_AdapterType() const;\r
56         CString Get_IPAddr ( int nIndex ) const;\r
57         CString Get_Subnet ( int nIndex ) const;\r
58         CString Get_DNSAddr ( int nIndex ) const;\r
59         CString Get_GatewayAddr ( int nIndex ) const;\r
60         void Set_PhysicalAddress ( int nPhysicalAddressLength, BYTE *pPhysicalAddress );\r
61         CString Get_PhysicalAddressStr () { return MacAddress2String ( m_nPhysicalAddressLength, m_PhysicalAddress ); }\r
62 \r
63 private:\r
64         BOOL Init ();\r
65         BOOL RenewReleaseIP( Func_OperateIP func );\r
66 \r
67 public:\r
68         BOOL m_bInitOk;\r
69 private:\r
70         IP_ADAPTER_INFO         m_AdptInfo;\r
71         CString                         m_csName;\r
72         CString                         m_csDesc;\r
73         t_IPINFO                        m_CurIPInfo;    // this is also in the ip address list but this is the address currently active.        \r
74         t_Ary_IPINFO            m_Ary_IP;\r
75         CStringArray            m_Ary_DNS;\r
76         CStringArray            m_Ary_Gateway;\r
77         BYTE                            m_PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];\r
78         int                                     m_nPhysicalAddressLength;\r
79 };\r
80 \r
81 class CNetAdapterInfo\r
82 {\r
83 public:\r
84         CNetAdapterInfo ();\r
85         ~CNetAdapterInfo();\r
86         int GetNetCardCount () { return m_Ary_NetAdapterInfo.GetSize(); }\r
87         COneNetAdapterInfo* Get_OneNetAdapterInfo ( int nIndex );\r
88         COneNetAdapterInfo* CNetAdapterInfo::Get_OneNetAdapterInfo ( DWORD dwIndex );\r
89         void Refresh ();\r
90 \r
91 private:\r
92         int EnumNetworkAdapters ();\r
93         void DeleteAllNetAdapterInfo();\r
94         BOOL GetAdapterAddress ();\r
95 \r
96 private:\r
97         CPtrArray m_Ary_NetAdapterInfo;\r
98 };\r
99 \r
100 #endif // !defined(AFX_OneNetAdapterInfo_H__A899410F_5CFF_4958_80C4_D1AC693F62E3__INCLUDED_)\r