added initial version of the network cpl

svn path=/trunk/; revision=10209
This commit is contained in:
Gero Kuehn 2004-07-18 22:37:08 +00:00
parent 5633682080
commit cd35daab59
15 changed files with 1114 additions and 1 deletions

View file

@ -6,7 +6,7 @@ PATH_TO_TOP = ../..
include $(PATH_TO_TOP)/rules.mak
CONTROL_PANELS = access appwiz control sysdm
CONTROL_PANELS = access appwiz ncpa sysdm control
all: $(CONTROL_PANELS)

View file

@ -0,0 +1,16 @@
*.coff
*.cpl
*.d
*.a
*.o
*.sym
*.map
*.tmp
*.ncb
*.opt
*.plg
*.~*
dummy*.*
Debug
Release

View file

@ -0,0 +1,47 @@
# $Id: Makefile,v 1.1 2004/07/18 22:37:07 kuehng Exp $
PATH_TO_TOP = ../../..
TARGET_TYPE = dynlink
TARGET_EXTENSION = .cpl
TARGET_NAME = ncpa
TARGET_INSTALLDIR = system32
TARGET_BASE = $(TARGET_BASE_LIB_CPL_SYSDM)
TARGET_CFLAGS = \
-I./include \
-DUNICODE \
-D_UNICODE \
-D__REACTOS__ \
-Wall \
-Werror \
-fno-builtin
TARGET_LFLAGS = -nostartfiles
TARGET_SDKLIBS = kernel32.a user32.a comctl32.a iphlpapi.a
TARGET_GCCLIBS = gcc
TARGET_PCH =
TARGET_CLEAN =
TARGET_OBJECTS = ncpa.o
DEP_OBJECTS = $(TARGET_OBJECTS)
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
%/TAGS:
etags -o $(@D)/TAGS $(@D)/\*.c
etags: ./TAGS

661
reactos/lib/cpl/ncpa/ncpa.c Normal file
View file

@ -0,0 +1,661 @@
/*
* Copyright 2004 Gero Kuehn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: ncpa.c,v 1.1 2004/07/18 22:37:07 kuehng Exp $
*
* PROJECT: ReactOS Network Control Panel
* FILE: lib/cpl/system/ncpa.c
* PURPOSE: ReactOS Network Control Panel
* PROGRAMMER: Gero Kuehn (reactos.filter@gkware.com)
* UPDATE HISTORY:
* 07-18-2004 Created
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Read this first !
//
// This file contains a first attempt for reactos network configuration
// This is:
// - not complete
// - not the way it works on Windows
//
// A lot of code that can be found here now, will probably be relocated into the OS core or some
// protocol Co-Installers or Notify Objects later when all the required COM
// and "netcfgx.dll" infrastructure (esp. headers and Interfaces) get implemented step by step.
//
// This code is only a first approach to provide a usable network configuration dialogs for
// the new network support in Reactos.
//
// If you intend to extend this code by more, please contact me to avoid duplicate work.
// There are already resources and code for TCP/IP configuration that are not
// mature enough for committing them to CVS yet.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <tchar.h>
#include <windows.h>
#ifdef __REACTOS__
//#include <Netcfgn.h>
#else
#include <commctrl.h>
#include <cpl.h>
#endif
#include "resource.h"
#include "ncpa.h"
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// useful utilities
#define NCF_HIDDEN 0x08
#define NCF_HAS_UI 0x80
typedef void (ENUMREGKEYCALLBACK)(void *pCookie,HKEY hBaseKey,TCHAR *pszSubKey);
void EnumRegKeys(ENUMREGKEYCALLBACK *pCallback,void *pCookie,HKEY hBaseKey,TCHAR *tpszRegPath)
{
HKEY hKey;
int i;
LONG ret;
TCHAR tpszName[MAX_PATH];
DWORD dwNameLen = sizeof(tpszName);
if(RegOpenKeyEx(hBaseKey,tpszRegPath,0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS)
{
OutputDebugString(_T("EnumRegKeys failed (key not found)\r\n"));
OutputDebugString(tpszRegPath);
OutputDebugString(_T("\r\n"));
return;
}
for(i=0;;i++)
{
TCHAR pszNewPath[MAX_PATH];
ret = RegEnumKeyEx(hKey,i,tpszName,&dwNameLen,NULL,NULL,NULL,NULL);
if(ret != ERROR_SUCCESS)
{
OutputDebugString(_T("EnumRegKeys: RegEnumKeyEx failed\r\n"));
break;
}
_stprintf(pszNewPath,_T("%s\\%s"),tpszRegPath,tpszName);
OutputDebugString(_T("EnumRegKeys: Calling user supplied enum function\r\n"));
pCallback(pCookie,hBaseKey,pszNewPath);
dwNameLen = sizeof(tpszName);
}
RegCloseKey(hKey);
}
void InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc,LPARAM lParam)
{
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
psp->dwSize = sizeof(PROPSHEETPAGE);
psp->dwFlags = PSP_DEFAULT;
psp->hInstance = hApplet;
#ifdef _MSC_VER
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
#else
psp->u1.pszTemplate = MAKEINTRESOURCE(idDlg);
#endif
psp->pfnDlgProc = DlgProc;
psp->lParam = lParam;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
LONG CALLBACK DisplayApplet(VOID);
BOOL CALLBACK NetworkPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
//void DisplayTCPIPProperties(HWND hParent,IP_ADAPTER_INFO *pInfo);
HINSTANCE hApplet = 0;
/* Applets */
APPLET Applets[] =
{
{IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, DisplayApplet}
};
BOOL FindNICClassKeyForCfgInstance(TCHAR *tpszCfgInst,TCHAR *tpszSubKeyOut)
{
int i;
TCHAR tpszSubKey[MAX_PATH];
TCHAR tpszCfgInst2[MAX_PATH];
HKEY hKey;
DWORD dwType,dwSize;
for(i=0;i<100;i++)
{
_stprintf(tpszSubKey,_T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%04d"),i);
if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
continue;
dwType = REG_SZ;
if(RegQueryValueEx(hKey,_T("NetCfgInstanceId"),NULL,&dwType,(BYTE*)tpszCfgInst2,&dwSize)!=ERROR_SUCCESS) {
RegCloseKey(hKey);
continue;
}
RegCloseKey(hKey);
if(_tcscmp(tpszCfgInst,tpszCfgInst2)==0) {
_tcscpy(tpszSubKeyOut,tpszSubKey);
return TRUE;
}
}
return FALSE;
}
void NICPropertyProtocolCallback(void *pCookie,HKEY hBaseKey,TCHAR *tpszSubKey)
{
HWND hwndDlg;
DWORD dwCharacteristics;
HKEY hKey,hNDIKey;
DWORD dwType,dwSize;
TCHAR tpszDescription[MAX_PATH];
TCHAR tpszNotifyObjectCLSID[MAX_PATH];
// CLSID CLSID_NotifObj;
// IUnknown *pUnk = NULL;
// INetCfgComponentControl *pNetCfg;
// INetCfgComponentPropertyUi *pNetCfgPropUI;
hwndDlg = (HWND)pCookie;
if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
return;
dwType = REG_DWORD;
dwSize = sizeof(dwCharacteristics);
if(RegQueryValueEx(hKey,_T("Characteristics"),NULL,&dwType,(BYTE*)&dwCharacteristics,&dwSize)!= ERROR_SUCCESS)
return;
if(dwCharacteristics & NCF_HIDDEN) {
RegCloseKey(hKey);
return;
}
dwType = REG_SZ;
dwSize = sizeof(tpszDescription);
if(RegQueryValueEx(hKey,_T("Description"),NULL,&dwType,(BYTE*)tpszDescription,&dwSize)!= ERROR_SUCCESS)
return;
RegOpenKey(hKey,_T("Ndi"),&hNDIKey);
dwType = REG_SZ;
dwSize = sizeof(tpszNotifyObjectCLSID);
if(RegQueryValueEx(hNDIKey,_T("ClsId"),NULL,&dwType,(BYTE*)tpszNotifyObjectCLSID,&dwSize)!= ERROR_SUCCESS)
;//return;
RegCloseKey(hNDIKey);
//
// Thise code works on Windows... but not on Reactos
//
// CLSIDFromString(tpszNotifyObjectCLSID,&CLSID_NotifObj);
// CoCreateInstance(&CLSID_NotifObj,NULL,CLSCTX_INPROC_SERVER,&IID_IUnknown,(void**)&pUnk);
// pUnk->lpVtbl->QueryInterface(pUnk,&IID_INetCfgComponentControl,(void**)&pNetCfg);
// pUnk->lpVtbl->QueryInterface(pUnk,&IID_INetCfgComponentPropertyUi,(void**)&pNetCfgPropUI);
{
/*
HRESULT hr;
hr = pNetCfg->lpVtbl->Initialize(pNetCfg,&NetCfgComponent,&NetCfg,FALSE);
hr = pNetCfgPropUI->lpVtbl->QueryPropertyUi(pNetCfgPropUI,(INetCfg*)&NetCfg);
hr = pNetCfgPropUI->lpVtbl->SetContext(pNetCfgPropUI,(INetCfg*)&NetCfgComponent);
DWORD dwNumPages = 10;
HPROPSHEETPAGE *bOut = NULL;
UINT nPages;
hr = pNetCfgPropUI->MergePropPages(&dwNumPages,(BYTE**)&bOut,&nPages,GetDesktopWindow(),NULL);
*/
}
RegCloseKey(hKey);
SendDlgItemMessage(hwndDlg,IDC_COMPONENTSLIST,LB_ADDSTRING,0,(LPARAM)tpszDescription);
}
BOOL CALLBACK NICPropertyPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PROPSHEETPAGE *pPage = (PROPSHEETPAGE *)GetWindowLong(hwndDlg,GWL_USERDATA);
switch(uMsg)
{
case WM_INITDIALOG:
{
TCHAR *tpszCfgInstanceID;
DWORD dwType,dwSize;
TCHAR tpszSubKey[MAX_PATH];
TCHAR tpszDisplayName[MAX_PATH];
HKEY hKey;
pPage = (PROPSHEETPAGE *)lParam;
tpszCfgInstanceID = (TCHAR*)pPage->lParam;
if(!FindNICClassKeyForCfgInstance(tpszCfgInstanceID,tpszSubKey))
MessageBox(hwndDlg,_T("NIC Entry not found"),_T("Registry error"),MB_ICONSTOP);
if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
return 0;
dwType = REG_SZ;
dwSize = sizeof(tpszDisplayName);
if(RegQueryValueEx(hKey,_T("DriverDesc"),NULL,&dwType,(BYTE*)tpszDisplayName,&dwSize)!= ERROR_SUCCESS)
return 0;
RegCloseKey(hKey);
SetDlgItemText(hwndDlg,IDC_NETCARDNAME,tpszDisplayName);
EnableWindow(GetDlgItem(hwndDlg,IDC_CONFIGURE),FALSE);
SetWindowLong(hwndDlg,GWL_USERDATA,lParam);
//SetDlgItemTextA(hwndDlg,IDC_NETCARDNAME,Info[pPage->lParam].Description);
EnumRegKeys(NICPropertyProtocolCallback,hwndDlg,HKEY_LOCAL_MACHINE,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E975-E325-11CE-BFC1-08002BE10318}"));
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_COMPONENTSLIST:
if(HIWORD(wParam)!=LBN_DBLCLK)
break;
// drop though
case IDC_PROPERTIES:
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);
// DisplayTCPIPProperties(hwndDlg,&Info[pPage->lParam]);
break;
}
break;
}
return FALSE;
}
void DisplayNICProperties(HWND hParent,TCHAR *tpszCfgInstanceID)
{
PROPSHEETPAGE psp[1];
PROPSHEETHEADER psh;
TCHAR tpszSubKey[MAX_PATH];
HKEY hKey;
DWORD dwType = REG_SZ;
TCHAR tpszName[MAX_PATH];
DWORD dwSize = sizeof(tpszName);
// Get the "Name" for this Connection
_stprintf(tpszSubKey,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID);
if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
return;
if(RegQueryValueEx(hKey,_T("Name"),NULL,&dwType,(BYTE*)tpszName,&dwSize)!=ERROR_SUCCESS)
_stprintf(tpszName,_T("[ERROR]"));
//_stprintf(tpszName,_T("[ERROR]") _T(__FILE__) _T(" %d"),__LINE__ );
else
_tcscat(tpszName,_T(" Properties"));
RegCloseKey(hKey);
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
#ifdef _MSC_VER
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
#else
psh.u1.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
#endif
psh.pszCaption = tpszName;
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
#ifdef _MSC_VER
psh.nStartPage = 0;
psh.ppsp = psp;
#else
psh.u2.nStartPage = 0;
psh.u3.ppsp = psp;
#endif
psh.pfnCallback = NULL;
InitPropSheetPage(&psp[0], IDD_NETPROPERTIES, NICPropertyPageProc,(LPARAM)tpszCfgInstanceID);
PropertySheet(&psh) ;
return;
}
BOOL CALLBACK NICStatusPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
PROPSHEETPAGE *psp= (PROPSHEETPAGE *)lParam;
EnableWindow(GetDlgItem(hwndDlg,IDC_ENDISABLE),FALSE);
SetWindowLong(hwndDlg,DWL_USER,psp->lParam);
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_PROPERTIES:
{
TCHAR *tpszCfgInstance;
tpszCfgInstance = (TCHAR*)GetWindowLong(hwndDlg,DWL_USER);
DisplayNICProperties(hwndDlg,tpszCfgInstance);
}
break;
}
break;
}
return FALSE;
}
void DisplayNICStatus(HWND hParent,TCHAR *tpszCfgInstanceID)
{
PROPSHEETPAGE psp[1];
PROPSHEETHEADER psh;
TCHAR tpszSubKey[MAX_PATH];
HKEY hKey;
DWORD dwType = REG_SZ;
TCHAR tpszName[MAX_PATH];
DWORD dwSize = sizeof(tpszName);
// Get the "Name" for this Connection
_stprintf(tpszSubKey,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID);
if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
return;
if(RegQueryValueEx(hKey,_T("Name"),NULL,&dwType,(BYTE*)tpszName,&dwSize)!=ERROR_SUCCESS)
_stprintf(tpszName,_T("[ERROR]"));
//_stprintf(tpszName,_T("[ERROR]") _T(__FILE__) _T(" %d"),__LINE__ );
else
_tcscat(tpszName,_T(" Status"));
RegCloseKey(hKey);
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
// FIX THESE REACTOS HEADERS !!!!!!!!!
#ifdef _MSC_VER
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
#else
psh.u1.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
#endif
psh.pszCaption = tpszName;//Caption;
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
#ifdef _MSC_VER
psh.nStartPage = 0;
psh.ppsp = psp;
#else
psh.u2.nStartPage = 0;
psh.u3.ppsp = psp;
#endif
psh.pfnCallback = NULL;
InitPropSheetPage(&psp[0], IDD_CARDPROPERTIES, NICStatusPageProc,(LPARAM)tpszCfgInstanceID);
PropertySheet(&psh) ;
return;
}
//
// IPHLPAPI does not provide a list of all adapters
//
/*
void EnumAdapters(HWND hwndDlg)
{
IP_ADAPTER_INFO *pInfo;
ULONG size=sizeof(Info);
TCHAR pszText[MAX_ADAPTER_NAME_LENGTH + 4];
int nIndex;
if(GetAdaptersInfo(Info,&size)!=ERROR_SUCCESS)
{
MessageBox(hwndDlg,L"IPHLPAPI.DLL failed to provide Adapter information",L"Error",MB_ICONSTOP);
return;
}
pInfo = &Info[0];
while(pInfo)
{
swprintf(pszText,L"%S",Info[0].Description);
nIndex = SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_ADDSTRING,0,(LPARAM)pszText);
SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETITEMDATA,nIndex,(LPARAM)pInfo);
pInfo = pInfo->Next;
}
}
*/
void NetAdapterCallback(void *pCookie,HKEY hBaseKey,TCHAR *tpszSubKey)
{
TCHAR tpszDisplayName[MAX_PATH];
//TCHAR tpszDeviceID[MAX_PATH];
TCHAR tpszCfgInstanceID[MAX_PATH];
TCHAR *ptpszCfgInstanceID;
HKEY hKey;
DWORD dwType = REG_SZ;
DWORD dwSize = sizeof(tpszDisplayName);
int nIndex;
HWND hwndDlg = (HWND)pCookie;
DWORD dwCharacteristics;
OutputDebugString(_T("NetAdapterCallback\r\n"));
OutputDebugString(tpszSubKey);
OutputDebugString(_T("\r\n"));
if(RegOpenKeyEx(hBaseKey,tpszSubKey,0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS)
return;
OutputDebugString(_T("NetAdapterCallback: Reading Characteristics\r\n"));
dwType = REG_DWORD;
dwSize = sizeof(dwCharacteristics);
if(RegQueryValueEx(hKey,_T("Characteristics"),NULL,&dwType,(BYTE*)&dwCharacteristics,&dwSize)!=ERROR_SUCCESS)
dwCharacteristics = 0;
if(dwCharacteristics & NCF_HIDDEN)
return;
// if(!(dwCharacteristics & NCF_HAS_UI))
// return;
OutputDebugString(_T("NetAdapterCallback: Reading DriverDesc\r\n"));
dwType = REG_SZ;
dwSize = sizeof(tpszDisplayName);
if(RegQueryValueEx(hKey,_T("DriverDesc"),NULL,&dwType,(BYTE*)tpszDisplayName,&dwSize)!= ERROR_SUCCESS)
_tcscpy(tpszDisplayName,_T("Unnamed Adapter"));
// get the link to the Enum Subkey (currently unused)
//dwType = REG_SZ;
//dwSize = sizeof(tpszDeviceID);
//if(RegQueryValueEx(hKey,_T("MatchingDeviceId"),NULL,&dwType,(BYTE*)tpszDeviceID,&dwSize) != ERROR_SUCCESS) {
// MessageBox(hwndDlg,_T("Missing MatchingDeviceId Entry"),_T("Registry Problem"),MB_ICONSTOP);
// return;
//}
// get the card configuration GUID
dwType = REG_SZ;
dwSize = sizeof(tpszCfgInstanceID);
if(RegQueryValueEx(hKey,_T("NetCfgInstanceId"),NULL,&dwType,(BYTE*)tpszCfgInstanceID,&dwSize) != ERROR_SUCCESS) {
MessageBox(hwndDlg,_T("Missing NetCfgInstanceId Entry"),_T("Registry Problem"),MB_ICONSTOP);
return;
}
ptpszCfgInstanceID = _tcsdup(tpszCfgInstanceID);
//
// **TODO** **FIXME** TBD
// At this point, we should verify, if the device listed here
// really represents a device that is currently connected to the system
//
// How is this done properly ?
nIndex = SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_ADDSTRING,0,(LPARAM)tpszDisplayName);
SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETITEMDATA,nIndex,(LPARAM)ptpszCfgInstanceID);
RegCloseKey(hKey);
}
void EnumAdapters(HWND hwndDlg)
{
TCHAR *tpszRegPath = _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}");
EnumRegKeys(NetAdapterCallback,hwndDlg,HKEY_LOCAL_MACHINE,tpszRegPath);
return;
}
BOOL CALLBACK NetworkPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
NMHDR* pnmh;
int nIndex;
switch(uMsg)
{
case WM_INITDIALOG:
{
EnableWindow(GetDlgItem(hwndDlg,IDC_ADD),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVE),FALSE);
SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETCURSEL,0,0);
EnumAdapters(hwndDlg);
}
break;
case WM_NOTIFY:
pnmh=(NMHDR*)lParam;
switch(pnmh->code) {
case PSN_APPLY:
case PSN_RESET:
{
while(SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_GETCOUNT,0,0)>0)
{
TCHAR *tpszString;
tpszString = (TCHAR*)SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_GETITEMDATA,0,0);
if(tpszString)
free(tpszString);
SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_DELETESTRING,0,0);
}
}
break;
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_NETCARDLIST:
if(HIWORD(wParam)==LBN_DBLCLK) {
nIndex = SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_GETCURSEL,0,0);
if(nIndex!=-1)
DisplayNICStatus(hwndDlg,(TCHAR*)SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_GETITEMDATA,nIndex,0));
}
break;
case IDC_PROPERTIES:
nIndex = SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_GETCURSEL,0,0);
if(nIndex!=-1)
DisplayNICStatus(hwndDlg,(TCHAR*)SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_GETITEMDATA,nIndex,0));
break;
}
break;
}
return FALSE;
}
/* First Applet */
LONG CALLBACK DisplayApplet(VOID)
{
PROPSHEETPAGE psp[1];
PROPSHEETHEADER psh;
TCHAR Caption[1024];
LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE;
psh.hwndParent = NULL;
psh.hInstance = hApplet;
#ifdef _MSC_VER
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
#else
psh.u1.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
#endif
psh.pszCaption = Caption;
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
#ifdef _MSC_VER
psh.nStartPage = 0;
psh.ppsp = psp;
#else
psh.u2.nStartPage = 0;
psh.u3.ppsp = psp;
#endif
psh.pfnCallback = NULL;
InitPropSheetPage(&psp[0], IDD_PROPPAGENETWORK, NetworkPageProc,0);
return (LONG)(PropertySheet(&psh) != -1);
}
/* Control Panel Callback */
LONG CALLBACK CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
{
int i = (int)lParam1;
switch(uMsg)
{
case CPL_INIT:
{
return TRUE;
}
case CPL_GETCOUNT:
{
return sizeof(Applets)/sizeof(APPLET);
}
case CPL_INQUIRE:
{
CPLINFO *CPlInfo = (CPLINFO*)lParam2;
CPlInfo->lData = 0;
CPlInfo->idIcon = Applets[i].idIcon;
CPlInfo->idName = Applets[i].idName;
CPlInfo->idInfo = Applets[i].idDescription;
break;
}
case CPL_DBLCLK:
{
Applets[i].AppletProc();
break;
}
}
return FALSE;
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
hApplet = hinstDLL;
break;
}
return TRUE;
}

View file

@ -0,0 +1,6 @@
LIBRARY ncpa.cpl
EXPORTS
CPlApplet
; EOF

View file

@ -0,0 +1,136 @@
# Microsoft Developer Studio Project File - Name="ncpa" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=ncpa - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ncpa.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ncpa.mak" CFG="ncpa - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ncpa - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "ncpa - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "ncpa - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ncpa_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "ncpa_EXPORTS" /D "_UNICODE" /D "UNICODE" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_MSC_VER"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib iphlpapi.lib /nologo /dll /machine:I386 /out:"Release/ncpa.cpl"
!ELSEIF "$(CFG)" == "ncpa - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ncpa_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "ncpa_EXPORTS" /D "_UNICODE" /D "UNICODE" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_MSC_VER"
# SUBTRACT RSC /x
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib iphlpapi.lib /nologo /dll /debug /machine:I386 /out:"Debug/ncpa.cpl" /pdbtype:sept
!ENDIF
# Begin Target
# Name "ncpa - Win32 Release"
# Name "ncpa - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\Makefile
# End Source File
# Begin Source File
SOURCE=.\ncpa.c
# End Source File
# Begin Source File
SOURCE=.\ncpa.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\tcpip_properties.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\ncpa.def
# End Source File
# Begin Source File
SOURCE=.\ncpa.rc
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\resources\applet.ico
# End Source File
# End Group
# End Target
# End Project

View file

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "ncpa"=.\ncpa.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View file

@ -0,0 +1,6 @@
LIBRARY appwiz.cpl
EXPORTS
CPlApplet=CPlApplet@16
; EOF

View file

@ -0,0 +1,20 @@
#ifndef __CPL_APPWIZ_H
#define __CPL_APPWIZ_H
typedef LONG (CALLBACK *CPLAPPLET_PROC)(VOID);
typedef struct
{
int idIcon;
int idName;
int idDescription;
CPLAPPLET_PROC AppletProc;
} APPLET, *PAPPLET;
extern HINSTANCE hApplet;
void ShowLastWin32Error(HWND hWndOwner);
#endif /* __CPL_APPWIZ_H */
/* EOF */

View file

@ -0,0 +1,134 @@
#include "resource.h"
#ifdef _MSC_VER
#include <../../../include/reactos/resource.h>
#include <../../../include/defines.h>
#else
#include <reactos/resource.h>
#include <defines.h>
#endif
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
VS_VERSION_INFO VERSIONINFO
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", RES_STR_COMPANY_NAME
VALUE "FileDescription", "ReactOS Network Control Panel\0"
VALUE "FileVersion", RES_STR_FILE_VERSION
VALUE "InternalName", "ncpa\0"
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
VALUE "OriginalFilename", "ncpa.cpl\0"
VALUE "ProductName", RES_STR_PRODUCT_NAME
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
IDI_CPLSYSTEM ICON "resources/applet.ico"
IDI_HORIZONTAL ICON "resources/horiz.ICO"
IDI_VERTICAL ICON "resources/vertic.ico"
IDI_NETSTAT ICON "resources/netconn.ico"
IDD_PROPPAGENETWORK DIALOG DISCARDABLE 0, 0, 246, 228
STYLE DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION ""
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Network Adapters",-1,9,9,217,8
LISTBOX IDC_NETCARDLIST,9,21,229,73,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Add",IDC_ADD,9,100,60,14
PUSHBUTTON "&Remove",IDC_REMOVE,72,100,60,14
PUSHBUTTON "&Properties",IDC_PROPERTIES,179,100,60,14
END
IDD_NETPROPERTIES DIALOG DISCARDABLE 0, 0, 246, 228
STYLE DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "General"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Connect Using:", -1, 9,9,217,8
EDITTEXT IDC_NETCARDNAME, 9, 21, 230, 12, WS_DISABLED | WS_BORDER | WS_TABSTOP
PUSHBUTTON "&Configure", IDC_CONFIGURE, 189, 38, 50, 14
LTEXT "Components checked are used by this connection:", -1, 9, 59, 217, 8
LISTBOX IDC_COMPONENTSLIST, 9, 71, 230, 67, LBS_STANDARD
PUSHBUTTON "&Install", IDC_INSTALL, 9, 130, 65, 14, WS_DISABLED | WS_TABSTOP
PUSHBUTTON "&Uninstall", IDC_UNINSTALL, 90, 130, 65, 14, WS_DISABLED | WS_TABSTOP
PUSHBUTTON "&Properties", IDC_PROPERTIES, 174, 130, 65, 14
GROUPBOX "Description", -1, 9, 153, 230, 46, BS_GROUPBOX | WS_DISABLED
LTEXT "Component Description goes here...", IDC_DESCRIPTION, 15, 165, 217, 28, WS_DISABLED | WS_GROUP
CHECKBOX "Show Icon in taskbar when connected", IDC_SHOWTASKBAR, 9, 206, 230, 12, BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP
END
IDD_CARDPROPERTIES DIALOG DISCARDABLE 0, 0, 200,180
STYLE DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "General"
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Connection", -1, 9, 8, 182, 58, BS_GROUPBOX
LTEXT "Status:", -1, 19, 20, 60, 8
LTEXT "Duration:", -1, 19, 34, 60, 8
LTEXT "Speed:", -1, 19, 48, 60, 8
GROUPBOX "Activity", -1, 9, 74, 182, 70, BS_GROUPBOX
RTEXT "Sent", -1, 26, 90, 60, 8
ICON IDI_HORIZONTAL, -1, 90, 85, 18, 20
ICON IDI_NETSTAT, -1, 110, 85, 18, 20
ICON IDI_HORIZONTAL, -1, 130, 85, 18, 20
LTEXT "Received", -1, 149, 90, 37, 8
LTEXT "Packets:", -1, 17, 115, 32, 8
RTEXT "000.000.000", IDC_SEND, 63, 115, 44, 8
ICON IDI_VERTICAL, -1, 110, 108, 18, 20
RTEXT "000.000.000", IDC_RECEIVED, 139, 115, 44, 8
PUSHBUTTON "&Properties", IDC_PROPERTIES, 10, 150, 50, 14
PUSHBUTTON "&Disable", IDC_ENDISABLE, 66, 150, 50, 14
END
IDD_TCPIPPROPERTIES DIALOG DISCARDABLE 0, 0, 246, 228
STYLE DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "General"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "You can get IP settings assigned automatically if your network supports this capability. Otherwise, you need to ask your network administrator for the appropriate IP settings.", -1, 9, 9, 228, 27
CONTROL "Obtain the IP address automatically", IDC_USEDHCP, "BUTTON", BS_AUTORADIOBUTTON | WS_GROUP, 14, 43, 210, 12
GROUPBOX "", -1, 9, 61, 228, 70, BS_GROUPBOX
CONTROL "&Use the following IP address:", IDC_NODHCP, "BUTTON", BS_AUTORADIOBUTTON, 14, 59, 105, 12
LTEXT "IP address:", -1, 14, 75, 135, 8
CONTROL "",IDC_IPADDR,"SysIPAddress32",0,150,75-2,80,12
LTEXT "Subnet mask:", -1, 14, 90, 135, 8
CONTROL "",IDC_SUBNETMASK,"SysIPAddress32",0,150,90-2,80,12
LTEXT "Default gateway:", -1, 14, 105, 135, 8
CONTROL "",IDC_DEFGATEWAY,"SysIPAddress32",0,150,105-2,80,12
CONTROL "Obtain the DNS server address automatically", IDC_AUTODNS, "BUTTON", BS_AUTORADIOBUTTON | WS_GROUP, 14, 139, 210, 12
GROUPBOX "", -1, 9, 157, 228, 47, BS_GROUPBOX
CONTROL "&Use the following DNS server addresses", IDC_FIXEDDNS, "BUTTON", BS_AUTORADIOBUTTON, 14, 155, 142, 12
LTEXT "Preferred DNS server:", -1, 14, 171, 135, 8
CONTROL "",IDC_DNS1,"SysIPAddress32",0,150,171-2,80,12
LTEXT "Alternate DNS server:", -1, 14, 186, 135, 8
CONTROL "",IDC_DNS2,"SysIPAddress32",0,150,186-2,80,12
PUSHBUTTON "&Advanced", IDC_ADVANCED, 186, 209, 50, 14, WS_DISABLED | WS_TABSTOP
}
STRINGTABLE
BEGIN
IDS_CPLSYSTEMNAME "Network Properties"
IDS_CPLSYSTEMDESCRIPTION "Customizes network settings."
END

View file

@ -0,0 +1,58 @@
#ifndef __CPL_RESOURCE_H
#define __CPL_RESOURCE_H
/* metrics */
#define PROPSHEETWIDTH 246
#define PROPSHEETHEIGHT 228
#define PROPSHEETPADDING 6
#define SYSTEM_COLUMN (0 * PROPSHEETPADDING)
// this is not supported by the MS Resource compiler:
//#define LABELLINE(x) 0 //(((PROPSHEETPADDING + 2) * x) + (x + 2))
#define ICONSIZE 16
/* ids */
#define IDI_CPLSYSTEM 100
#define IDI_HORIZONTAL 101
#define IDI_VERTICAL 102
#define IDI_NETSTAT 103
#define IDD_PROPPAGENETWORK 100
#define IDD_CARDPROPERTIES 101
#define IDD_NETPROPERTIES 102
#define IDD_TCPIPPROPERTIES 103
#define IDS_CPLSYSTEMNAME 1001
#define IDS_CPLSYSTEMDESCRIPTION 2001
/* controls */
#define IDC_NETCARDLIST 100
#define IDC_ADD 101
#define IDC_REMOVE 102
#define IDC_PROPERTIES 103
#define IDC_NETCARDNAME 104
#define IDC_CONFIGURE 105
#define IDC_COMPONENTSLIST 106
#define IDC_INSTALL 107
#define IDC_UNINSTALL 108
//#define IDC_PROPERTIES 109
#define IDC_DESCRIPTION 110
#define IDC_SHOWTASKBAR 111
#define IDC_SEND 112
#define IDC_RECEIVED 113
#define IDC_ENDISABLE 114
#define IDC_USEDHCP 115
#define IDC_NODHCP 116
#define IDC_AUTODNS 117
#define IDC_FIXEDDNS 118
#define IDC_ADVANCED 119
#define IDC_IPADDR 120
#define IDC_SUBNETMASK 121
#define IDC_DEFGATEWAY 122
#define IDC_DNS1 123
#define IDC_DNS2 124
#endif /* __CPL_RESOURCE_H */
/* EOF */

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB