3 * Copyright (C) 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS Network Control Panel
22 * FILE: lib/cpl/system/tcpip_properties.c
23 * PURPOSE: ReactOS Network Control Panel
24 * PROGRAMMER: Gero Kuehn (reactos.filter@gkware.com)
44 // this is missing on reactos...
45 #ifndef IPM_SETADDRESS
46 #define IPM_SETADDRESS (WM_USER+101)
55 extern void InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
);
58 TCPIPPropertyPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
60 PROPSHEETPAGE
*pPage
= (PROPSHEETPAGE
*)GetWindowLongPtr(hwndDlg
,GWL_USERDATA
);
61 IP_ADAPTER_INFO
*pInfo
= NULL
;
63 pInfo
= (IP_ADAPTER_INFO
*)pPage
->lParam
;
68 pPage
= (PROPSHEETPAGE
*)lParam
;
69 pInfo
= (IP_ADAPTER_INFO
*)pPage
->lParam
;
70 EnableWindow(GetDlgItem(hwndDlg
,IDC_ADVANCED
),FALSE
);
71 SetWindowLongPtr(hwndDlg
,GWL_USERDATA
,(DWORD_PTR
)pPage
->lParam
);
73 if(pInfo
->DhcpEnabled
) {
74 CheckDlgButton(hwndDlg
,IDC_USEDHCP
,BST_CHECKED
);
75 CheckDlgButton(hwndDlg
,IDC_NODHCP
,BST_UNCHECKED
);
77 CheckDlgButton(hwndDlg
,IDC_USEDHCP
,BST_UNCHECKED
);
78 CheckDlgButton(hwndDlg
,IDC_NODHCP
,BST_CHECKED
);
83 IP_ADDR_STRING
*pString
;
84 pString
= &pInfo
->IpAddressList
;
86 pString
= pString
->Next
;
87 sscanf(pString
->IpAddress
.String
,"%d.%d.%d.%d",&b
[0],&b
[1],&b
[2],&b
[3]);
88 dwIPAddr
= b
[0]<<24|b
[1]<<16|b
[2]<<8|b
[3];
89 SendDlgItemMessage(hwndDlg
,IDC_IPADDR
,IPM_SETADDRESS
,0,dwIPAddr
);
90 sscanf(pString
->IpMask
.String
,"%d.%d.%d.%d",&b
[0],&b
[1],&b
[2],&b
[3]);
91 dwIPAddr
= b
[0]<<24|b
[1]<<16|b
[2]<<8|b
[3];
92 SendDlgItemMessage(hwndDlg
,IDC_SUBNETMASK
,IPM_SETADDRESS
,0,dwIPAddr
);
94 pString
= &pInfo
->GatewayList
;
96 pString
= pString
->Next
;
97 sscanf(pString
->IpAddress
.String
,"%d.%d.%d.%d",&b
[0],&b
[1],&b
[2],&b
[3]);
98 dwIPAddr
= b
[0]<<24|b
[1]<<16|b
[2]<<8|b
[3];
99 SendDlgItemMessage(hwndDlg
,IDC_DEFGATEWAY
,IPM_SETADDRESS
,0,dwIPAddr
);
103 TCHAR pszRegKey
[MAX_PATH
];
105 _stprintf(pszRegKey
,_T("SYSTEM\\CurrentControlSet\\Services\\TCPIP\\Parameters\\Interfaces\\%S"),pInfo
->AdapterName
);
106 if(RegOpenKey(HKEY_LOCAL_MACHINE
,pszRegKey
,&hKey
)==ERROR_SUCCESS
)
108 char pszDNS
[MAX_PATH
];
109 DWORD dwSize
= sizeof(pszDNS
);
110 DWORD dwType
= REG_SZ
;
113 RegQueryValueExA(hKey
,"NameServer",NULL
,&dwType
,(BYTE
*)pszDNS
,&dwSize
);
116 sscanf(pszDNS
,"%d.%d.%d.%d,%d.%d.%d.%d",&b
[0][0],&b
[0][1],&b
[0][2],&b
[0][3],&b
[1][0],&b
[1][1],&b
[1][2],&b
[1][3]);
117 dwIPAddr
= b
[0][0]<<24|b
[0][1]<<16|b
[0][2]<<8|b
[0][3];
118 SendDlgItemMessage(hwndDlg
,IDC_DNS1
,IPM_SETADDRESS
,0,dwIPAddr
);
119 dwIPAddr
= b
[1][0]<<24|b
[1][1]<<16|b
[1][2]<<8|b
[1][3];
120 SendDlgItemMessage(hwndDlg
,IDC_DNS2
,IPM_SETADDRESS
,0,dwIPAddr
);
121 CheckDlgButton(hwndDlg
,IDC_FIXEDDNS
,TRUE
);
122 EnableWindow(GetDlgItem(hwndDlg
,IDC_DNS1
),FALSE
);
123 EnableWindow(GetDlgItem(hwndDlg
,IDC_DNS2
),FALSE
);
124 EnableWindow(GetDlgItem(hwndDlg
,IDC_AUTODNS
),FALSE
);
125 EnableWindow(GetDlgItem(hwndDlg
,IDC_FIXEDDNS
),FALSE
);
131 switch(LOWORD(wParam
))
139 void DisplayTCPIPProperties(HWND hParent
,IP_ADAPTER_INFO
*pInfo
)
141 PROPSHEETPAGE psp
[1];
143 INITCOMMONCONTROLSEX cce
;
145 cce
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
146 cce
.dwICC
= ICC_INTERNET_CLASSES
;
147 InitCommonControlsEx(&cce
);
149 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
150 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
151 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_NOAPPLYNOW
;
152 psh
.hwndParent
= hParent
;
153 psh
.hInstance
= hApplet
;
154 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
155 psh
.pszCaption
= NULL
;//Caption;
156 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
159 psh
.pfnCallback
= NULL
;
162 InitPropSheetPage(&psp
[0], IDD_TCPIPPROPERTIES
, TCPIPPropertyPageProc
);
163 psp
[0].lParam
= (LPARAM
)pInfo
;
165 if (PropertySheet(&psh
) == -1)
167 MessageBox(hParent
,_T("Unable to create property sheet"),_T("Error"),MB_ICONSTOP
);