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

Louis. Lenders xerox_xerox2000 at yahoo.co.uk
Wed Oct 25 16:38:00 CDT 2006


Hi , i added some more error checking, and changed
some  
things according to Rob Shearman's remarks. Hopefully
correct now.
 
 Changelog: Get HW_PROFILE_INFO from registry 
 (partially based on patch from Ben Collins)
 
 
 	
 	
 

Send instant messages to your online friends http://uk.messenger.yahoo.com 
-------------- 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..54b31b0 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,78 @@ 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;
+
+      if(RPC_S_OK != RpcStringFreeA(&StringUuid))
+        goto error;
+      }
+
+    if(ERROR_SUCCESS != RegGetValueA(hkey, 0, "HwProfileGuid", RRF_RT_REG_SZ, 0, pInfo->szHwProfileGuid, &size))
+      goto error;
+
+    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;
+      }
+
+    if(ERROR_SUCCESS !=RegGetValueA(hkey, 0, "FriendlyName", RRF_RT_REG_SZ, 0, pInfo->szHwProfileName, &size))
+      goto error; 
+
+    if(ERROR_SUCCESS !=RegCloseKey(hkey))
+      goto error;
+
+    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;
+      }
+
+    if(ERROR_SUCCESS !=RegGetValueA(hkey, 0, "DockingState", RRF_RT_DWORD, 0, &pInfo->dwDockInfo, &size))
+      goto error;
+
+    if(ERROR_SUCCESS !=RegCloseKey(hkey))
+      goto error;
+
+    TRACE("DockInfo = %x, Profile Guid = %s, Friendly Name = %s\n", pInfo->dwDockInfo, pInfo->szHwProfileGuid, pInfo->szHwProfileName);
+
+    return 1;
+
+    error:
+      ERR("GetCurrentHwProfileA failed to update the HwProfile, returns FALSE\n");
+      RegCloseKey(hkey);
+      return FALSE;
 }
 
 /******************************************************************************


More information about the wine-patches mailing list