Add "Add hardware" control panel applet.
authorHervé Poussineau <hpoussin@reactos.org>
Mon, 3 Oct 2005 07:48:59 +0000 (07:48 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Mon, 3 Oct 2005 07:48:59 +0000 (07:48 +0000)
Not added to the build, as InstallNewDevice in newdev.dll is not implemented

svn path=/trunk/; revision=18239

reactos/baseaddress.xml
reactos/lib/cpl/hdwwiz/En.rc [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/Fr.rc [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/hdwwiz.c [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/hdwwiz.def [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/hdwwiz.h [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/hdwwiz.rc [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/hdwwiz.xml [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/resource.h [new file with mode: 0644]
reactos/lib/cpl/hdwwiz/resources/applet.ico [new file with mode: 0644]

index de4224b..2c22b42 100644 (file)
@@ -5,6 +5,7 @@
 <property name="BASEADDRESS_UXTHEME" value="0x5AD70000" />
 <property name="BASEADDRESS_OBJSEL" value="0x5B400000" />
 <property name="BASEADDRESS_DINPUT" value="0x5F580000" />
+<property name="BASEADDRESS_HDWWIZ" value="0x64D40000" />
 <property name="BASEADDRESS_TIMEDATE" value="0x64DA0000" />
 <property name="BASEADDRESS_SYSDM" value="0x64DD0000" />
 <property name="BASEADDRESS_MAIN" value="0x64F40000" />
diff --git a/reactos/lib/cpl/hdwwiz/En.rc b/reactos/lib/cpl/hdwwiz/En.rc
new file mode 100644 (file)
index 0000000..c7d84bb
--- /dev/null
@@ -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 (file)
index 0000000..9cc8497
--- /dev/null
@@ -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 (file)
index 0000000..f6606a0
--- /dev/null
@@ -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 <windows.h>
+#include <commctrl.h>
+#include <setupapi.h>
+#include <cpl.h>
+#include <tchar.h>
+#include <stdio.h>
+
+#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 (file)
index 0000000..4b6a44b
--- /dev/null
@@ -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 (file)
index 0000000..7005fdb
--- /dev/null
@@ -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 (file)
index 0000000..7533149
--- /dev/null
@@ -0,0 +1,21 @@
+#include <windows.h>
+
+#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 <reactos/version.rc>
+#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 (file)
index 0000000..9b766b9
--- /dev/null
@@ -0,0 +1,13 @@
+<module name="hdwwiz" type="win32dll" extension=".cpl" baseaddress="${BASEADDRESS_HDWWIZ}" installbase="system32" installname="hdwwiz.cpl">
+       <importlibrary definition="hdwwiz.def" />
+       <include base="hdwwiz">.</include>
+       <define name="UNICODE" />
+       <define name="_UNICODE" />
+       <define name="__REACTOS__" />
+       <define name="__USE_W32API" />
+       <define name="_WIN32_IE">0x600</define>
+       <define name="_WIN32_WINNT">0x501</define>
+       <library>setupapi</library>
+       <file>hdwwiz.c</file>
+       <file>hdwwiz.rc</file>
+</module>
diff --git a/reactos/lib/cpl/hdwwiz/resource.h b/reactos/lib/cpl/hdwwiz/resource.h
new file mode 100644 (file)
index 0000000..864e7b8
--- /dev/null
@@ -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 (file)
index 0000000..3eae16d
Binary files /dev/null and b/reactos/lib/cpl/hdwwiz/resources/applet.ico differ