From 7a6054e30a9cf0d6204a290400b9cdf43f9b71eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 3 Oct 2005 07:48:59 +0000 Subject: [PATCH] Add "Add hardware" control panel applet. Not added to the build, as InstallNewDevice in newdev.dll is not implemented svn path=/trunk/; revision=18239 --- reactos/baseaddress.xml | 1 + reactos/lib/cpl/hdwwiz/En.rc | 7 + reactos/lib/cpl/hdwwiz/Fr.rc | 7 + reactos/lib/cpl/hdwwiz/hdwwiz.c | 146 ++++++++++++++++++++ reactos/lib/cpl/hdwwiz/hdwwiz.def | 6 + reactos/lib/cpl/hdwwiz/hdwwiz.h | 16 +++ reactos/lib/cpl/hdwwiz/hdwwiz.rc | 21 +++ reactos/lib/cpl/hdwwiz/hdwwiz.xml | 13 ++ reactos/lib/cpl/hdwwiz/resource.h | 12 ++ reactos/lib/cpl/hdwwiz/resources/applet.ico | Bin 0 -> 1398 bytes 10 files changed, 229 insertions(+) create mode 100644 reactos/lib/cpl/hdwwiz/En.rc create mode 100644 reactos/lib/cpl/hdwwiz/Fr.rc create mode 100644 reactos/lib/cpl/hdwwiz/hdwwiz.c create mode 100644 reactos/lib/cpl/hdwwiz/hdwwiz.def create mode 100644 reactos/lib/cpl/hdwwiz/hdwwiz.h create mode 100644 reactos/lib/cpl/hdwwiz/hdwwiz.rc create mode 100644 reactos/lib/cpl/hdwwiz/hdwwiz.xml create mode 100644 reactos/lib/cpl/hdwwiz/resource.h create mode 100644 reactos/lib/cpl/hdwwiz/resources/applet.ico diff --git a/reactos/baseaddress.xml b/reactos/baseaddress.xml index de4224ba446..2c22b42473d 100644 --- a/reactos/baseaddress.xml +++ b/reactos/baseaddress.xml @@ -5,6 +5,7 @@ + diff --git a/reactos/lib/cpl/hdwwiz/En.rc b/reactos/lib/cpl/hdwwiz/En.rc new file mode 100644 index 00000000000..c7d84bb501e --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/En.rc @@ -0,0 +1,7 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE +BEGIN + IDS_CPLNAME "Add hardware" + IDS_CPLDESCRIPTION "Add hardware to your computer." +END diff --git a/reactos/lib/cpl/hdwwiz/Fr.rc b/reactos/lib/cpl/hdwwiz/Fr.rc new file mode 100644 index 00000000000..9cc8497a055 --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/Fr.rc @@ -0,0 +1,7 @@ +LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_CPLNAME "Ajout de matériel" + IDS_CPLDESCRIPTION "Ajoute un nouveau matériel ŕ votre ordinateur." +END diff --git a/reactos/lib/cpl/hdwwiz/hdwwiz.c b/reactos/lib/cpl/hdwwiz/hdwwiz.c new file mode 100644 index 00000000000..f6606a0a385 --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/hdwwiz.c @@ -0,0 +1,146 @@ +/* + * ReactOS New devices installation + * Copyright (C) 2005 ReactOS Team + * + * 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 + */ +/* + * PROJECT: ReactOS Add hardware control panel + * FILE: lib/cpl/hdwwiz/hdwwiz.c + * PURPOSE: ReactOS Add hardware control panel + * PROGRAMMER: Hervé Poussineau (hpoussin@reactos.org) + */ + +#include +#include +#include +#include +#include +#include + +#include "resource.h" +#include "hdwwiz.h" + +LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam); +HINSTANCE hApplet = 0; + +/* Applets */ +APPLET Applets[] = +{ + {IDI_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet} +}; + +typedef BOOL (*PINSTALL_NEW_DEVICE)(HWND, LPGUID, PDWORD); + +LONG APIENTRY +Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam) +{ + HMODULE hNewDev = NULL; + PINSTALL_NEW_DEVICE InstallNewDevice; + DWORD Reboot; + BOOL ret; + LONG rc; + + hNewDev = LoadLibrary(_T("newdev.dll")); + if (!hNewDev) + { + rc = 1; + goto cleanup; + } + + InstallNewDevice = (PINSTALL_NEW_DEVICE)GetProcAddress(hNewDev, (LPCSTR)"InstallNewDevice"); + if (!InstallNewDevice) + { + rc = 2; + goto cleanup; + } + + ret = InstallNewDevice(hwnd, NULL, &Reboot); + if (!ret) + { + rc = 3; + goto cleanup; + } + + if (Reboot != DI_NEEDRESTART && Reboot != DI_NEEDREBOOT) + { + /* We're done with installation */ + rc = 0; + goto cleanup; + } + + /* We need to reboot */ + if (SetupPromptReboot(NULL, hwnd, FALSE) == -1) + { + /* User doesn't want to reboot, or an error occurred */ + rc = 5; + goto cleanup; + } + + rc = 0; + +cleanup: + if (hNewDev != NULL) + FreeLibrary(hNewDev); + return rc; +} + +/* 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(Applets[0]); + + 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(hwndCpl, uMsg, lParam1, lParam2); + break; + } + } + return FALSE; +} + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) +{ + switch(dwReason) + { + case DLL_PROCESS_ATTACH: + hApplet = hinstDLL; + break; + } + return TRUE; +} diff --git a/reactos/lib/cpl/hdwwiz/hdwwiz.def b/reactos/lib/cpl/hdwwiz/hdwwiz.def new file mode 100644 index 00000000000..4b6a44b65b8 --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/hdwwiz.def @@ -0,0 +1,6 @@ +LIBRARY hdwwiz.cpl + +EXPORTS +CPlApplet@16 + +; EOF diff --git a/reactos/lib/cpl/hdwwiz/hdwwiz.h b/reactos/lib/cpl/hdwwiz/hdwwiz.h new file mode 100644 index 00000000000..7005fdb3de8 --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/hdwwiz.h @@ -0,0 +1,16 @@ +#ifndef __CPL_HDWWIZ_H +#define __CPL_HDWWIZ_H + +typedef struct +{ + int idIcon; + int idName; + int idDescription; + APPLET_PROC AppletProc; +} APPLET, *PAPPLET; + +extern HINSTANCE hApplet; + +#endif /* __CPL_HDWWIZ_H */ + +/* EOF */ diff --git a/reactos/lib/cpl/hdwwiz/hdwwiz.rc b/reactos/lib/cpl/hdwwiz/hdwwiz.rc new file mode 100644 index 00000000000..7533149d608 --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/hdwwiz.rc @@ -0,0 +1,21 @@ +#include + +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Software Control Panel\0" +#define REACTOS_STR_INTERNAL_NAME "hdwwiz\0" +#define REACTOS_STR_ORIGINAL_FILENAME "hdwwiz.cpl\0" + +#ifdef _MSC_VER +#include <../../../reactos/version.rc> +#else +#include +#endif + +IDI_CPLICON ICON "resources/applet.ico" + +#include "En.rc" +#include "Fr.rc" diff --git a/reactos/lib/cpl/hdwwiz/hdwwiz.xml b/reactos/lib/cpl/hdwwiz/hdwwiz.xml new file mode 100644 index 00000000000..9b766b99cff --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/hdwwiz.xml @@ -0,0 +1,13 @@ + + + . + + + + + 0x600 + 0x501 + setupapi + hdwwiz.c + hdwwiz.rc + diff --git a/reactos/lib/cpl/hdwwiz/resource.h b/reactos/lib/cpl/hdwwiz/resource.h new file mode 100644 index 00000000000..864e7b879d8 --- /dev/null +++ b/reactos/lib/cpl/hdwwiz/resource.h @@ -0,0 +1,12 @@ +#ifndef __CPL_RESOURCE_H +#define __CPL_RESOURCE_H + +/* ids */ + +#define IDI_CPLICON 1 +#define IDS_CPLNAME 2 +#define IDS_CPLDESCRIPTION 3 + +#endif /* __CPL_RESOURCE_H */ + +/* EOF */ diff --git a/reactos/lib/cpl/hdwwiz/resources/applet.ico b/reactos/lib/cpl/hdwwiz/resources/applet.ico new file mode 100644 index 0000000000000000000000000000000000000000..3eae16df58c7f5b9a6b80827d788f7416afccbda GIT binary patch literal 1398 zcmds1v2MaJ5Pcy?>6oosVPx#onJ?g5x|yL8-r%#mb?JxX50cHi7sup4K?uN%Pj@Bxs|$P2s|z*`B_b@H#sH*;X6HIy|)ae`;;G(4U3c%KwU zng}6K%Mtq*G0LLw(UgYY#`a*~ft@q>4}8aK8_?=J=D_=@^L_oC@Gbu>Zm!E|ecnu( z+`8Q-9);RO1DVO`5*Ex${7*rzT$k>q>YY}5t123;JHup-7leVI7nk`P|W&Ys_ z_r*N>-jMqObGQP}oF-9>st~smS_|yFs$V?oA+Ep34wa~LO!6G5 MKQVRI!ab7Xj@&-27XSbN literal 0 HcmV?d00001