2 * Copyright 2004 Gero Kuehn
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * PROJECT: ReactOS Network Control Panel
21 * FILE: lib/cpl/system/ncpa.c
22 * PURPOSE: ReactOS Network Control Panel
23 * PROGRAMMER: Gero Kuehn (reactos.filter@gkware.com)
31 * This file contains a first attempt for reactos network configuration
33 * - It is not complete.
34 * - It does not work the way it works on Windows.
36 * A lot of code that can be found here now, will probably be relocated into the OS core or some
37 * protocol Co-Installers or Notify Objects later when all the required COM
38 * and "netcfgx.dll" infrastructure (esp. headers and Interfaces) get implemented step by step.
40 * This code is only a first approach to provide a usable network configuration dialogs for
41 * the new network support in Reactos.
43 * If you intend to extend this code by more, please contact me to avoid duplicate work.
44 * There are already resources and code for TCP/IP configuration that are not
45 * mature enough for committing them to CVS yet.
57 //#include <Netcfgn.h>
64 #define NCF_HIDDEN 0x08
65 #define NCF_HAS_UI 0x80
67 typedef void (ENUMREGKEYCALLBACK
)(void *pCookie
,HKEY hBaseKey
,TCHAR
*pszSubKey
);
69 static LONG CALLBACK
DisplayApplet(VOID
);
70 static INT_PTR CALLBACK
NetworkPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
71 void DisplayTCPIPProperties(HWND hParent
,IP_ADAPTER_INFO
*pInfo
);
73 HINSTANCE hApplet
= 0;
76 static APPLET Applets
[] =
78 {IDI_CPLSYSTEM
, IDS_CPLSYSTEMNAME
, IDS_CPLSYSTEMDESCRIPTION
, DisplayApplet
}
83 /* useful utilities */
85 EnumRegKeys(ENUMREGKEYCALLBACK
*pCallback
,PVOID pCookie
,HKEY hBaseKey
,TCHAR
*tpszRegPath
)
90 TCHAR tpszName
[MAX_PATH
];
91 DWORD dwNameLen
= sizeof(tpszName
);
93 if(RegOpenKeyEx(hBaseKey
,tpszRegPath
,0,KEY_ALL_ACCESS
,&hKey
)!=ERROR_SUCCESS
)
95 OutputDebugString(_T("EnumRegKeys failed (key not found)\r\n"));
96 OutputDebugString(tpszRegPath
);
97 OutputDebugString(_T("\r\n"));
103 TCHAR pszNewPath
[MAX_PATH
];
104 ret
= RegEnumKeyEx(hKey
,i
,tpszName
,&dwNameLen
,NULL
,NULL
,NULL
,NULL
);
105 if(ret
!= ERROR_SUCCESS
)
107 OutputDebugString(_T("EnumRegKeys: RegEnumKeyEx failed for\r\n"));
108 OutputDebugString(tpszName
);
109 OutputDebugString(_T("\r\n"));
113 _stprintf(pszNewPath
,_T("%s\\%s"),tpszRegPath
,tpszName
);
114 OutputDebugString(_T("EnumRegKeys: Calling user supplied enum function\r\n"));
115 pCallback(pCookie
,hBaseKey
,pszNewPath
);
117 dwNameLen
= sizeof(tpszName
);
124 InitPropSheetPage(PROPSHEETPAGE
*psp
, WORD idDlg
, DLGPROC DlgProc
,LPARAM lParam
)
126 ZeroMemory(psp
, sizeof(PROPSHEETPAGE
));
127 psp
->dwSize
= sizeof(PROPSHEETPAGE
);
128 psp
->dwFlags
= PSP_DEFAULT
;
129 psp
->hInstance
= hApplet
;
130 psp
->pszTemplate
= MAKEINTRESOURCE(idDlg
);
131 psp
->pfnDlgProc
= DlgProc
;
132 psp
->lParam
= lParam
;
138 FindNICClassKeyForCfgInstance(TCHAR
*tpszCfgInst
,TCHAR
*tpszSubKeyOut
)
141 TCHAR tpszSubKey
[MAX_PATH
];
142 TCHAR tpszCfgInst2
[MAX_PATH
];
146 for (i
= 0; i
< 100; i
++)
148 _stprintf(tpszSubKey
,_T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%04d"),i
);
149 if(RegOpenKey(HKEY_LOCAL_MACHINE
,tpszSubKey
,&hKey
)!=ERROR_SUCCESS
)
152 dwSize
= sizeof(tpszCfgInst2
);
153 if(RegQueryValueEx(hKey
,_T("NetCfgInstanceId"),NULL
,&dwType
,(BYTE
*)tpszCfgInst2
,&dwSize
)!=ERROR_SUCCESS
) {
158 if(_tcscmp(tpszCfgInst
,tpszCfgInst2
)==0) {
159 _tcscpy(tpszSubKeyOut
,tpszSubKey
);
168 NICPropertyProtocolCallback(void *pCookie
,HKEY hBaseKey
,TCHAR
*tpszSubKey
)
171 DWORD dwCharacteristics
;
174 TCHAR tpszDescription
[MAX_PATH
];
175 TCHAR tpszNotifyObjectCLSID
[MAX_PATH
];
176 TCHAR
*tpszSubKeyCopy
;
178 // CLSID CLSID_NotifObj;
179 // IUnknown *pUnk = NULL;
180 // INetCfgComponentControl *pNetCfg;
181 // INetCfgComponentPropertyUi *pNetCfgPropUI;
182 hwndDlg
= (HWND
)pCookie
;
184 if(RegOpenKey(HKEY_LOCAL_MACHINE
,tpszSubKey
,&hKey
)!=ERROR_SUCCESS
)
188 dwSize
= sizeof(dwCharacteristics
);
189 if(RegQueryValueEx(hKey
,_T("Characteristics"),NULL
,&dwType
,(BYTE
*)&dwCharacteristics
,&dwSize
)!= ERROR_SUCCESS
)
192 if(dwCharacteristics
& NCF_HIDDEN
)
199 dwSize
= sizeof(tpszDescription
);
200 if(RegQueryValueEx(hKey
,_T("Description"),NULL
,&dwType
,(BYTE
*)tpszDescription
,&dwSize
)!= ERROR_SUCCESS
)
203 RegOpenKey(hKey
,_T("Ndi"),&hNDIKey
);
205 dwSize
= sizeof(tpszNotifyObjectCLSID
);
206 if(RegQueryValueEx(hNDIKey
,_T("ClsId"),NULL
,&dwType
,(BYTE
*)tpszNotifyObjectCLSID
,&dwSize
)!= ERROR_SUCCESS
)
209 RegCloseKey(hNDIKey
);
212 // This code works on Windows... but not on Reactos
215 // CLSIDFromString(tpszNotifyObjectCLSID,&CLSID_NotifObj);
216 // CoCreateInstance(&CLSID_NotifObj,NULL,CLSCTX_INPROC_SERVER,&IID_IUnknown,(void**)&pUnk);
217 // pUnk->lpVtbl->QueryInterface(pUnk,&IID_INetCfgComponentControl,(void**)&pNetCfg);
218 // pUnk->lpVtbl->QueryInterface(pUnk,&IID_INetCfgComponentPropertyUi,(void**)&pNetCfgPropUI);
222 hr = pNetCfg->lpVtbl->Initialize(pNetCfg,&NetCfgComponent,&NetCfg,FALSE);
223 hr = pNetCfgPropUI->lpVtbl->QueryPropertyUi(pNetCfgPropUI,(INetCfg*)&NetCfg);
224 hr = pNetCfgPropUI->lpVtbl->SetContext(pNetCfgPropUI,(INetCfg*)&NetCfgComponent);
225 DWORD dwNumPages = 10;
226 HPROPSHEETPAGE *bOut = NULL;
228 hr = pNetCfgPropUI->MergePropPages(&dwNumPages,(BYTE**)&bOut,&nPages,GetDesktopWindow(),NULL);
233 nIndex
= SendDlgItemMessage(hwndDlg
,IDC_COMPONENTSLIST
,LB_ADDSTRING
,0,(LPARAM
)tpszDescription
);
234 tpszSubKeyCopy
= _tcsdup(tpszSubKey
);
235 SendDlgItemMessage(hwndDlg
,IDC_COMPONENTSLIST
,LB_SETITEMDATA
,nIndex
,(LPARAM
)tpszSubKeyCopy
);
240 static INT_PTR CALLBACK
241 NICPropertyPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
243 PROPSHEETPAGE
*pPage
= (PROPSHEETPAGE
*)GetWindowLongPtr(hwndDlg
,GWL_USERDATA
);
248 TCHAR
*tpszCfgInstanceID
;
250 TCHAR tpszSubKey
[MAX_PATH
];
251 TCHAR tpszDisplayName
[MAX_PATH
];
253 pPage
= (PROPSHEETPAGE
*)lParam
;
254 tpszCfgInstanceID
= (TCHAR
*)pPage
->lParam
;
255 if(!FindNICClassKeyForCfgInstance(tpszCfgInstanceID
,tpszSubKey
))
257 MessageBox(hwndDlg
,_T("NIC Entry not found"),_T("Registry error"),MB_ICONSTOP
);
258 MessageBox(hwndDlg
,tpszCfgInstanceID
,tpszSubKey
,MB_ICONSTOP
);
261 if(RegOpenKey(HKEY_LOCAL_MACHINE
,tpszSubKey
,&hKey
)!=ERROR_SUCCESS
)
264 dwSize
= sizeof(tpszDisplayName
);
265 if(RegQueryValueEx(hKey
,_T("DriverDesc"),NULL
,&dwType
,(BYTE
*)tpszDisplayName
,&dwSize
)!= ERROR_SUCCESS
)
269 SetDlgItemText(hwndDlg
,IDC_NETCARDNAME
,tpszDisplayName
);
270 EnableWindow(GetDlgItem(hwndDlg
,IDC_CONFIGURE
),FALSE
);
273 SetWindowLongPtr(hwndDlg
,GWL_USERDATA
,(DWORD_PTR
)lParam
);
274 //SetDlgItemTextA(hwndDlg,IDC_NETCARDNAME,Info[pPage->lParam].Description);
275 EnumRegKeys(NICPropertyProtocolCallback
,hwndDlg
,HKEY_LOCAL_MACHINE
,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E975-E325-11CE-BFC1-08002BE10318}"));
280 switch(LOWORD(wParam
))
282 case IDC_COMPONENTSLIST
:
283 if(HIWORD(wParam
)==LBN_SELCHANGE
)
286 TCHAR tpszHelpKey
[MAX_PATH
];
287 TCHAR tpszHelpText
[MAX_PATH
];
290 HWND hListBox
= GetDlgItem(hwndDlg
,IDC_COMPONENTSLIST
);
291 tpszSubKey
= (TCHAR
*)SendMessage(hListBox
,LB_GETITEMDATA
,SendMessage(hListBox
,LB_GETCURSEL
,0,0),0);
294 _stprintf(tpszHelpKey
,_T("%s\\Ndi"),tpszSubKey
);
296 RegOpenKey(HKEY_LOCAL_MACHINE
,tpszHelpKey
,&hNDIKey
);
298 dwSize
= sizeof(tpszHelpText
);
299 if(RegQueryValueEx(hNDIKey
,_T("HelpText"),NULL
,&dwType
,(BYTE
*)tpszHelpText
,&dwSize
)!= ERROR_SUCCESS
)
301 RegCloseKey(hNDIKey
);
303 SetDlgItemText(hwndDlg
,IDC_DESCRIPTION
,tpszHelpText
);
306 if(HIWORD(wParam
)!=LBN_DBLCLK
)
312 TCHAR tpszNDIKey
[MAX_PATH
];
313 TCHAR tpszClsIDText
[MAX_PATH
];
314 TCHAR
*tpszTCPIPClsID
= _T("{A907657F-6FDF-11D0-8EFB-00C04FD912B2}");
317 HWND hListBox
= GetDlgItem(hwndDlg
,IDC_COMPONENTSLIST
);
318 tpszSubKey
= (TCHAR
*)SendMessage(hListBox
,LB_GETITEMDATA
,SendMessage(hListBox
,LB_GETCURSEL
,0,0),0);
321 _stprintf(tpszNDIKey
,_T("%s\\Ndi"),tpszSubKey
);
323 RegOpenKey(HKEY_LOCAL_MACHINE
,tpszNDIKey
,&hNDIKey
);
325 dwSize
= sizeof(tpszClsIDText
);
326 if(RegQueryValueEx(hNDIKey
,_T("ClsId"),NULL
,&dwType
,(BYTE
*)tpszClsIDText
,&dwSize
)!= ERROR_SUCCESS
)
328 RegCloseKey(hNDIKey
);
330 if(_tcscmp(tpszTCPIPClsID
,tpszClsIDText
)==0)
332 IP_ADAPTER_INFO Adapters
[64];
333 IP_ADAPTER_INFO
*pAdapter
;
334 TCHAR
*tpszCfgInstanceID
;
335 DWORD dwSize
= sizeof(Adapters
);
336 memset(&Adapters
,0x00,sizeof(Adapters
));
337 if(GetAdaptersInfo(Adapters
,&dwSize
)!=ERROR_SUCCESS
)
340 tpszCfgInstanceID
= (TCHAR
*)pPage
->lParam
;
343 TCHAR tpszAdatperName
[MAX_PATH
];
344 swprintf(tpszAdatperName
,L
"%S",pAdapter
->AdapterName
);
345 OutputDebugString(_T("IPHLPAPI returned:\r\n"));
346 OutputDebugString(tpszAdatperName
);
347 OutputDebugString(_T("\r\n"));
348 if(_tcscmp(tpszAdatperName
,tpszCfgInstanceID
)==0)
350 DisplayTCPIPProperties(hwndDlg
,pAdapter
);
354 OutputDebugString(_T("... which is not the TCPIP property sheet\r\n"));
356 pAdapter
= pAdapter
->Next
;
359 MessageBox(NULL
,_T("If you see this, then the IPHLPAPI.DLL probably needs more work because GetAdaptersInfo did not return the expected data."),_T("Error"),MB_ICONSTOP
);
365 MessageBox(NULL
,_T("This control panel is incomplete.\r\nUsually, the \"Notify Object\" for this Network component should be invoked here. Reactos lacks the infrastructure to do this right now.\r\n- C++\r\n- DDK Headers for notify objects\r\n- clean header structure, that allow Windows-Compatible COM C++ Code"),_T("Error"),MB_ICONSTOP
);
378 DisplayNICProperties(HWND hParent
,TCHAR
*tpszCfgInstanceID
)
380 PROPSHEETPAGE psp
[1];
382 TCHAR tpszSubKey
[MAX_PATH
];
384 DWORD dwType
= REG_SZ
;
385 TCHAR tpszName
[MAX_PATH
];
386 DWORD dwSize
= sizeof(tpszName
);
388 // Get the "Name" for this Connection
389 _stprintf(tpszSubKey
,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID
);
390 if(RegOpenKey(HKEY_LOCAL_MACHINE
,tpszSubKey
,&hKey
)!=ERROR_SUCCESS
)
392 if(RegQueryValueEx(hKey
,_T("Name"),NULL
,&dwType
,(BYTE
*)tpszName
,&dwSize
)!=ERROR_SUCCESS
)
393 _stprintf(tpszName
,_T("[ERROR]"));
395 _tcscat(tpszName
,_T(" Properties"));
399 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
400 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
401 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_NOAPPLYNOW
;
402 psh
.hwndParent
= hParent
;
403 psh
.hInstance
= hApplet
;
404 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
405 psh
.pszCaption
= tpszName
;
406 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
409 psh
.pfnCallback
= NULL
;
412 InitPropSheetPage(&psp
[0], IDD_NETPROPERTIES
, NICPropertyPageProc
,(LPARAM
)tpszCfgInstanceID
);
419 static INT_PTR CALLBACK
420 NICStatusPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
426 PROPSHEETPAGE
*psp
= (PROPSHEETPAGE
*)lParam
;
427 EnableWindow(GetDlgItem(hwndDlg
,IDC_ENDISABLE
),FALSE
);
428 SetWindowLongPtr(hwndDlg
,DWL_USER
,(DWORD_PTR
)psp
->lParam
);
432 switch(LOWORD(wParam
))
436 TCHAR
*tpszCfgInstance
;
437 tpszCfgInstance
= (TCHAR
*)GetWindowLong(hwndDlg
,DWL_USER
);
438 DisplayNICProperties(hwndDlg
,tpszCfgInstance
);
448 DisplayNICStatus(HWND hParent
,TCHAR
*tpszCfgInstanceID
)
450 PROPSHEETPAGE psp
[1];
452 TCHAR tpszSubKey
[MAX_PATH
];
454 DWORD dwType
= REG_SZ
;
455 TCHAR tpszName
[MAX_PATH
];
456 DWORD dwSize
= sizeof(tpszName
);
458 // Get the "Name" for this Connection
459 _stprintf(tpszSubKey
,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID
);
460 if (RegOpenKey(HKEY_LOCAL_MACHINE
,tpszSubKey
,&hKey
)!=ERROR_SUCCESS
)
463 if (RegQueryValueEx(hKey
,_T("Name"),NULL
,&dwType
,(BYTE
*)tpszName
,&dwSize
)!=ERROR_SUCCESS
)
464 _stprintf(tpszName
,_T("[ERROR]"));
465 //_stprintf(tpszName,_T("[ERROR]") _T(__FILE__) _T(" %d"),__LINE__ );
467 _tcscat(tpszName
,_T(" Status"));
470 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
471 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
472 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_NOAPPLYNOW
;
473 psh
.hwndParent
= hParent
;
474 psh
.hInstance
= hApplet
;
475 // FIX THESE REACTOS HEADERS !!!!!!!!!
476 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
477 psh
.pszCaption
= tpszName
;//Caption;
478 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
481 psh
.pfnCallback
= NULL
;
484 InitPropSheetPage(&psp
[0], IDD_CARDPROPERTIES
, NICStatusPageProc
,(LPARAM
)tpszCfgInstanceID
);
490 // IPHLPAPI does not provide a list of all adapters
494 EnumAdapters(HWND hwndDlg
)
496 TCHAR pszText
[MAX_ADAPTER_NAME_LENGTH
+ 4];
497 IP_ADAPTER_INFO
*pInfo
;
502 if(GetAdaptersInfo(Info
,&size
)!=ERROR_SUCCESS
)
504 MessageBox(hwndDlg
,L
"IPHLPAPI.DLL failed to provide Adapter information",L
"Error",MB_ICONSTOP
);
511 swprintf(pszText
,L
"%S",Info
[0].Description
);
512 nIndex
= SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_ADDSTRING
,0,(LPARAM
)pszText
);
513 SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_SETITEMDATA
,nIndex
,(LPARAM
)pInfo
);
522 NetAdapterCallback(void *pCookie
,HKEY hBaseKey
,TCHAR
*tpszSubKey
)
524 TCHAR tpszDisplayName
[MAX_PATH
];
525 //TCHAR tpszDeviceID[MAX_PATH];
526 TCHAR tpszCfgInstanceID
[MAX_PATH
];
527 TCHAR
*ptpszCfgInstanceID
;
529 DWORD dwType
= REG_SZ
;
530 DWORD dwSize
= sizeof(tpszDisplayName
);
532 HWND hwndDlg
= (HWND
)pCookie
;
533 DWORD dwCharacteristics
;
535 OutputDebugString(_T("NetAdapterCallback\r\n"));
536 OutputDebugString(tpszSubKey
);
537 OutputDebugString(_T("\r\n"));
538 if(RegOpenKeyEx(hBaseKey
,tpszSubKey
,0,KEY_ALL_ACCESS
,&hKey
)!=ERROR_SUCCESS
)
541 OutputDebugString(_T("NetAdapterCallback: Reading Characteristics\r\n"));
543 dwSize
= sizeof(dwCharacteristics
);
544 if(RegQueryValueEx(hKey
,_T("Characteristics"),NULL
,&dwType
,(BYTE
*)&dwCharacteristics
,&dwSize
)!=ERROR_SUCCESS
)
545 dwCharacteristics
= 0;
548 if (dwCharacteristics
& NCF_HIDDEN
)
550 // if (!(dwCharacteristics & NCF_HAS_UI))
553 OutputDebugString(_T("NetAdapterCallback: Reading DriverDesc\r\n"));
555 dwSize
= sizeof(tpszDisplayName
);
556 if (RegQueryValueEx(hKey
,_T("DriverDesc"),NULL
,&dwType
,(BYTE
*)tpszDisplayName
,&dwSize
)!= ERROR_SUCCESS
)
557 _tcscpy(tpszDisplayName
,_T("Unnamed Adapter"));
559 // get the link to the Enum Subkey (currently unused)
561 //dwSize = sizeof(tpszDeviceID);
562 //if(RegQueryValueEx(hKey,_T("MatchingDeviceId"),NULL,&dwType,(BYTE*)tpszDeviceID,&dwSize) != ERROR_SUCCESS) {
563 // MessageBox(hwndDlg,_T("Missing MatchingDeviceId Entry"),_T("Registry Problem"),MB_ICONSTOP);
567 // get the card configuration GUID
569 dwSize
= sizeof(tpszCfgInstanceID
);
570 if(RegQueryValueEx(hKey
,_T("NetCfgInstanceId"),NULL
,&dwType
,(BYTE
*)tpszCfgInstanceID
,&dwSize
) != ERROR_SUCCESS
) {
571 MessageBox(hwndDlg
,_T("Missing NetCfgInstanceId Entry"),_T("Registry Problem"),MB_ICONSTOP
);
575 ptpszCfgInstanceID
= _tcsdup(tpszCfgInstanceID
);
577 // **TODO** **FIXME** TBD
578 // At this point, we should verify, if the device listed here
579 // really represents a device that is currently connected to the system
581 // How is this done properly ?
584 nIndex
= SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_ADDSTRING
,0,(LPARAM
)tpszDisplayName
);
585 SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_SETITEMDATA
,nIndex
,(LPARAM
)ptpszCfgInstanceID
);
591 EnumAdapters(HWND hwndDlg
)
593 LPTSTR lpRegPath
= _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}");
595 EnumRegKeys(NetAdapterCallback
,hwndDlg
,HKEY_LOCAL_MACHINE
,lpRegPath
);
600 static INT_PTR CALLBACK
601 NetworkPageProc(HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
609 EnableWindow(GetDlgItem(hwndDlg
,IDC_ADD
),FALSE
);
610 EnableWindow(GetDlgItem(hwndDlg
,IDC_REMOVE
),FALSE
);
612 SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_SETCURSEL
,0,0);
614 EnumAdapters(hwndDlg
);
624 while(SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_GETCOUNT
,0,0)>0)
628 tpszString
= (TCHAR
*)SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_GETITEMDATA
,0,0);
631 SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_DELETESTRING
,0,0);
638 switch(LOWORD(wParam
))
640 case IDC_NETCARDLIST
:
641 if(HIWORD(wParam
)==LBN_DBLCLK
) {
642 nIndex
= SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_GETCURSEL
,0,0);
644 DisplayNICStatus(hwndDlg
,(TCHAR
*)SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_GETITEMDATA
,nIndex
,0));
649 nIndex
= SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_GETCURSEL
,0,0);
651 DisplayNICStatus(hwndDlg
,(TCHAR
*)SendDlgItemMessage(hwndDlg
,IDC_NETCARDLIST
,LB_GETITEMDATA
,nIndex
,0));
666 PROPSHEETPAGE psp
[1];
667 PROPSHEETHEADER psh
= {0};
670 LoadString(hApplet
, IDS_CPLSYSTEMNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
672 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
673 psh
.dwFlags
= PSH_PROPSHEETPAGE
;
674 psh
.hwndParent
= NULL
;
675 psh
.hInstance
= hApplet
;
676 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDI_CPLSYSTEM
));
677 psh
.pszCaption
= Caption
;
678 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGE
);
681 psh
.pfnCallback
= NULL
;
683 InitPropSheetPage(&psp
[0], IDD_PROPPAGENETWORK
, NetworkPageProc
,0);
685 return (LONG
)(PropertySheet(&psh
) != -1);
688 /* Control Panel Callback */
690 CPlApplet(HWND hwndCPl
, UINT uMsg
, LPARAM lParam1
, LPARAM lParam2
)
701 return sizeof(Applets
)/sizeof(APPLET
);
706 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
708 CPlInfo
->idIcon
= Applets
[(int)lParam1
].idIcon
;
709 CPlInfo
->idName
= Applets
[(int)lParam1
].idName
;
710 CPlInfo
->idInfo
= Applets
[(int)lParam1
].idDescription
;
716 Applets
[(int)lParam1
].AppletProc();
725 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD dwReason
, LPVOID lpvReserved
)
729 case DLL_PROCESS_ATTACH
:
730 case DLL_THREAD_ATTACH
: