forgot to add this file
authorThomas Bluemel <thomas@reactsoft.com>
Sat, 26 Nov 2005 03:25:57 +0000 (03:25 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Sat, 26 Nov 2005 03:25:57 +0000 (03:25 +0000)
svn path=/trunk/; revision=19605

reactos/lib/devmgr/advprop.c [new file with mode: 0644]

diff --git a/reactos/lib/devmgr/advprop.c b/reactos/lib/devmgr/advprop.c
new file mode 100644 (file)
index 0000000..8ab3cf7
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ * ReactOS Device Manager Applet
+ * Copyright (C) 2004 - 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
+ */
+/* $Id: hwpage.c 19599 2005-11-26 02:12:58Z weiden $
+ *
+ * PROJECT:         ReactOS devmgr.dll
+ * FILE:            lib/devmgr/hwpage.c
+ * PURPOSE:         ReactOS Device Manager
+ * PROGRAMMER:      Thomas Weidenmueller <w3seek@reactos.com>
+ * UPDATE HISTORY:
+ *      04-04-2004  Created
+ */
+#include <precomp.h>
+
+#define NDEBUG
+#include <debug.h>
+
+typedef INT_PTR (WINAPI *PPROPERTYSHEETW)(LPCPROPSHEETHEADERW);
+
+/***************************************************************************
+ * NAME                                                         EXPORTED
+ *      DeviceAdvancedPropertiesW
+ *
+ * DESCRIPTION
+ *   Invokes the device properties dialog, this version may add some property pages
+ *   for some devices
+ *
+ * ARGUMENTS
+ *   hWndParent:    Handle to the parent window
+ *   lpMachineName: Machine Name, NULL is the local machine
+ *   lpDeviceID:    Specifies the device whose properties are to be shown
+ *
+ * RETURN VALUE
+ *   -1: if errors occured
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ * @unimplemented
+ */
+int
+WINAPI
+DeviceAdvancedPropertiesW(HWND hWndParent,
+                          LPCWSTR lpMachineName,
+                          LPCWSTR lpDeviceID)
+{
+    HDEVINFO hDevInfo;
+    SP_DEVINFO_DATA DevInfoData;
+    HINSTANCE hComCtl32;
+    PPROPERTYSHEETW pPropertySheetW;
+    int Ret = -1;
+
+    /* FIXME - handle remote device properties */
+
+    UNREFERENCED_PARAMETER(lpMachineName);
+
+    /* dynamically load comctl32 */
+    hComCtl32 = LoadAndInitComctl32();
+    if (hComCtl32 == NULL ||
+        !(pPropertySheetW = (PPROPERTYSHEETW)GetProcAddress(hComCtl32,
+                                                            "PropertySheetW")))
+    {
+        return -1;
+    }
+
+    hDevInfo = SetupDiCreateDeviceInfoList(NULL,
+                                           hWndParent);
+    if (hDevInfo == INVALID_HANDLE_VALUE)
+    {
+        goto Cleanup;
+    }
+
+    DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+    if (SetupDiOpenDeviceInfo(hDevInfo,
+                              lpDeviceID,
+                              hWndParent,
+                              0,
+                              &DevInfoData))
+    {
+        WCHAR szDevName[255];
+        DWORD RegDataType;
+        PROPSHEETHEADER psh = {0};
+        DWORD nPropSheets = 0;
+
+        /* get the device name */
+        if ((SetupDiGetDeviceRegistryProperty(hDevInfo,
+                                              &DevInfoData,
+                                              SPDRP_FRIENDLYNAME,
+                                              &RegDataType,
+                                              (PBYTE)szDevName,
+                                              sizeof(szDevName),
+                                              NULL) ||
+             SetupDiGetDeviceRegistryProperty(hDevInfo,
+                                              &DevInfoData,
+                                              SPDRP_DEVICEDESC,
+                                              &RegDataType,
+                                              (PBYTE)szDevName,
+                                              sizeof(szDevName),
+                                              NULL)) &&
+            RegDataType == REG_SZ)
+        {
+            /* FIXME - check string for NULL termination! */
+
+            psh.dwSize = sizeof(PROPSHEETHEADER);
+            psh.dwFlags =  PSH_PROPTITLE;
+            psh.pszCaption = szDevName;
+
+            /* find out how many property sheets we need */
+            if (SetupDiGetClassDevPropertySheets(hDevInfo,
+                                                 &DevInfoData,
+                                                 &psh,
+                                                 0,
+                                                 &nPropSheets,
+                                                 DIGCDP_FLAG_ADVANCED))
+            {
+                DPRINT1("SetupDiGetClassDevPropertySheets unexpectedly returned TRUE!\n");
+                goto Cleanup;
+            }
+
+            if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+            {
+                goto Cleanup;
+            }
+
+            psh.phpage = HeapAlloc(GetProcessHeap(),
+                                   0,
+                                   nPropSheets * sizeof(HPROPSHEETPAGE));
+            if (psh.phpage == NULL)
+            {
+                goto Cleanup;
+            }
+
+            if (!SetupDiGetClassDevPropertySheets(hDevInfo,
+                                                  &DevInfoData,
+                                                  &psh,
+                                                  nPropSheets,
+                                                  NULL,
+                                                  DIGCDP_FLAG_ADVANCED))
+            {
+                goto Cleanup;
+            }
+
+            /* FIXME - add "General" and "Driver" page */
+
+            Ret = pPropertySheetW(&psh);
+        }
+
+Cleanup:
+        HeapFree(GetProcessHeap(),
+                 0,
+                 psh.phpage);
+    }
+
+    SetupDiDestroyDeviceInfoList(hDevInfo);
+    FreeLibrary(hComCtl32);
+
+    return Ret;
+}
+
+/***************************************************************************
+ * NAME                                                         EXPORTED
+ *      DeviceAdvancedPropertiesA
+ *
+ * DESCRIPTION
+ *   Invokes the device properties dialog, this version may add some property pages
+ *   for some devices
+ *
+ * ARGUMENTS
+ *   hWndParent:    Handle to the parent window
+ *   lpMachineName: Machine Name, NULL is the local machine
+ *   lpDeviceID:    Specifies the device whose properties are to be shown
+ *
+ * RETURN VALUE
+ *   -1: if errors occured
+ *
+ * REVISIONS
+ *
+ * NOTE
+ *
+ * @unimplemented
+ */
+int
+WINAPI
+DeviceAdvancedPropertiesA(HWND hWndParent,
+                          LPCSTR lpMachineName,
+                          LPCSTR lpDeviceID)
+{
+    LPWSTR lpMachineNameW = NULL;
+    LPWSTR lpDeviceIDW = NULL;
+    int Ret = -1;
+
+    if (lpMachineName != NULL)
+    {
+        if (!(lpMachineNameW = ConvertMultiByteToUnicode(lpMachineName,
+                                                         CP_ACP)))
+        {
+            goto Cleanup;
+        }
+    }
+    if (lpDeviceID != NULL)
+    {
+        if (!(lpDeviceIDW = ConvertMultiByteToUnicode(lpDeviceID,
+                                                      CP_ACP)))
+        {
+            goto Cleanup;
+        }
+    }
+
+    Ret = DeviceAdvancedPropertiesW(hWndParent,
+                                    lpMachineNameW,
+                                    lpDeviceIDW);
+
+Cleanup:
+    HeapFree(GetProcessHeap(),
+             0,
+             lpMachineNameW);
+    HeapFree(GetProcessHeap(),
+             0,
+             lpDeviceIDW);
+
+    return Ret;
+}