advapi32:Get HW_PROFILE_INFO from registry (partially based on patch from Ben Collins) (try4)

Louis. Lenders xerox_xerox2000 at yahoo.co.uk
Fri Oct 27 07:24:32 CDT 2006


Skipped content of type multipart/alternative-------------- next part --------------
diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in
index 1b4cf5b..75eec4f 100644
--- a/dlls/advapi32/Makefile.in
+++ b/dlls/advapi32/Makefile.in
@@ -6,6 +6,7 @@ VPATH     = @srcdir@
 MODULE    = advapi32.dll
 IMPORTLIB = libadvapi32.$(IMPLIBEXT)
 IMPORTS   = kernel32 ntdll
+DELAYIMPORTS = rpcrt4
 
 C_SRCS = \
 	advapi.c \
diff --git a/dlls/advapi32/advapi.c b/dlls/advapi32/advapi.c
index 04a520a..07114ad 100644
--- a/dlls/advapi32/advapi.c
+++ b/dlls/advapi32/advapi.c
@@ -33,6 +33,7 @@ #include "winreg.h"
 #include "winternl.h"
 #include "winerror.h"
 #include "appmgmt.h"
+#include "rpc.h"
 
 #include "wine/library.h"
 #include "wine/debug.h"
@@ -116,11 +117,69 @@ GetUserNameW( LPWSTR lpszName, LPDWORD l
  */
 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
 {
-	FIXME("(%p) semi-stub\n", pInfo);
-	pInfo->dwDockInfo = DOCKINFO_DOCKED;
-	strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
-	strcpy(pInfo->szHwProfileName,"Wine Profile");
-	return 1;
+    UUID  Uuid;
+    unsigned char* StringUuid;
+    HKEY hkey;
+    DWORD size;
+    DWORD dockingstate = 0x00000000;
+    CHAR profilename[] = "Wine Profile";
+    CHAR profileguid[38];
+
+    if(ERROR_SUCCESS !=RegCreateKeyA(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles\\0001", &hkey))
+      goto error;
+
+    size = HW_PROFILE_GUIDLEN;
+    /*If the ProfileGuid is not in the registry, create it, and write it to the registry*/ 
+    if(ERROR_SUCCESS != RegGetValueA(hkey, 0, "HwProfileGuid", RRF_RT_REG_SZ, 0, pInfo->szHwProfileGuid, &size))
+      { 
+      if(RPC_S_OK != UuidCreate(&Uuid))
+        goto error;
+
+      if(RPC_S_OK != UuidToStringA( &Uuid , &StringUuid))
+        goto error;
+      /*The Guid is stored between brackets*/
+      sprintf(profileguid,"{%s}",StringUuid);
+
+      if(ERROR_SUCCESS != RegSetValueExA(hkey, "HwProfileGuid", 0, REG_SZ, (const BYTE*) profileguid, strlen( (const char *) profileguid)))
+        goto error;
+
+      RpcStringFreeA(&StringUuid);
+      }
+
+    strcpy( pInfo->szHwProfileGuid, profileguid);
+
+    size = MAX_PROFILE_LEN;
+    /*If the ProfileName is not in the registry create it, and write to the registry*/ 
+    if(ERROR_SUCCESS != RegGetValueA(hkey, 0, "FriendlyName", RRF_RT_REG_SZ, 0, pInfo->szHwProfileName, &size))
+      {
+      if(ERROR_SUCCESS !=RegSetValueExA(hkey, "FriendlyName", 0, REG_SZ, (const BYTE*) profilename, sizeof(profilename)))
+        goto error;
+      }
+
+    strcpy( pInfo->szHwProfileName, profilename); 
+    RegCloseKey(hkey);
+
+    if(ERROR_SUCCESS !=RegCreateKeyA(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\IDConfigDB\\CurrentDockInfo", &hkey))
+      goto error;
+
+    size = sizeof(DWORD);
+    /*If the DockingState is not in the registry create it, and write to the registry*/
+    if(ERROR_SUCCESS != RegGetValueA(hkey, 0, "DockingState", RRF_RT_DWORD , 0, &pInfo->dwDockInfo, &size))
+      {
+      if(ERROR_SUCCESS !=RegSetValueExA(hkey, "DockingState", 0, REG_DWORD, (const BYTE*) &dockingstate, sizeof(DWORD)))
+      goto error;
+      }
+
+    pInfo->dwDockInfo = dockingstate;
+
+    TRACE("DockInfo = %x, Profile Guid = %s, Friendly Name = %s\n", pInfo->dwDockInfo, pInfo->szHwProfileGuid, pInfo->szHwProfileName);
+
+    return TRUE;
+
+    error:
+      ERR("GetCurrentHwProfileA failed to update the HwProfile, returns FALSE\n");
+      if(hkey) RegCloseKey(hkey);
+      return FALSE;
 }
 
 /******************************************************************************


More information about the wine-patches mailing list