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

Louis. Lenders xerox_xerox2000 at yahoo.co.uk
Fri Oct 20 16:40:01 CDT 2006


fixes bug 4468. 

The ProfileGuid is now created "on the fly" with
UuidCreate. Further this patch checks if the
HW_PROFILE_INFO is present in the registry, and if
not, creates the values, and writes them to the
registry. There's not much error checking in this
patch, but that could be done later on. (if needed
anyway) 

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


	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html
-------------- next part --------------
diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in
index 1b4cf5b..da7aec4 100644
--- a/dlls/advapi32/Makefile.in
+++ b/dlls/advapi32/Makefile.in
@@ -5,7 +5,7 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = advapi32.dll
 IMPORTLIB = libadvapi32.$(IMPLIBEXT)
-IMPORTS   = kernel32 ntdll
+IMPORTS   = kernel32 ntdll rpcrt4
 
 C_SRCS = \
 	advapi.c \
diff --git a/dlls/advapi32/advapi.c b/dlls/advapi32/advapi.c
index 04a520a..fd2f576 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,54 @@ 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 __RPC_FAR* Uuid=0;
+    HKEY hkey;
+    DWORD size;
+    DWORD dockingstate = 0x00000000;
+    CHAR profilename[] = "Wine Profile";
+
+    RegCreateKeyA(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles\\0001", &hkey);
+
+    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))
+      { 
+      Uuid = HeapAlloc(GetProcessHeap(), 0, sizeof(*Uuid));
+
+      if(RPC_S_OK != UuidCreate(Uuid))
+        {
+        ERR("UuidCreate failed to create a UUID");
+        HeapFree( GetProcessHeap(), 0, Uuid );
+        return FALSE;
+        }
+
+      RegSetValueExA(hkey, "HwProfileGuid", 0, REG_SZ, (const BYTE*) debugstr_guid(Uuid), strlen(debugstr_guid(Uuid)));
+      }
+
+    RegGetValueA(hkey, 0, "HwProfileGuid", RRF_RT_REG_SZ, 0, pInfo->szHwProfileGuid, &size);
+    HeapFree( GetProcessHeap(), 0, Uuid );
+
+    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))
+    RegSetValueExA(hkey, "FriendlyName", 0, REG_SZ, (const BYTE*) profilename, sizeof(profilename));
+    RegGetValueA(hkey, 0, "FriendlyName", RRF_RT_REG_SZ, 0, pInfo->szHwProfileName, &size);
+
+    RegCloseKey(hkey);
+
+    RegCreateKeyA(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\IDConfigDB\\CurrentDockInfo", &hkey);
+
+    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))
+    RegSetValueExA(hkey, "DockingState", 0, REG_DWORD, (const BYTE*) &dockingstate, sizeof(DWORD));
+    RegGetValueA(hkey, 0, "DockingState", RRF_RT_DWORD, 0, &pInfo->dwDockInfo, &size);
+
+    RegCloseKey(hkey);
+
+    TRACE("DockInfo = %x, Profile Guid = %s, Friendly Name = %s\n", pInfo->dwDockInfo, pInfo->szHwProfileGuid, pInfo->szHwProfileName);
+
+    return 1;
 }
 
 /******************************************************************************


More information about the wine-patches mailing list