Home » U++ Library support » U++ Core » [FEATURE] Accessing to Alternate Win Registry View (patch included)
[FEATURE] Accessing to Alternate Win Registry View (patch included) [message #46574] |
Thu, 02 June 2016 16:46  |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi,
in a Win64 OS, the registry is divided in tow part.
by default, a binary compiled 64 bit, accees only to the 64 part of the rgistry
and a binary compiled 32 bit, accees only to the 32 part of the rgistry.
in order to accees to the 64 part, a 32 binary shall specify the key KEY_WOW64_64KEY.
in order to accees to the 32 part, a 64 binary shall specify the key KEY_WOW64_32KEY.
U++ now has this functions:
String GetWinRegString(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
int GetWinRegInt(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
bool SetWinRegString(const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
bool SetWinRegExpandString(const String& string, const char *value, const char *path, HKEY base_key);
bool SetWinRegInt(int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE);
void DeleteWinReg(const String& key, HKEY base = HKEY_LOCAL_MACHINE);
my proposal is to:
1 - Add a new dword argument to this funcions, with default value set to zero (0).
String GetWinRegString(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
int GetWinRegInt(const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
bool SetWinRegString(const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
bool SetWinRegExpandString(const String& string, const char *value, const char *path, HKEY base_key, dword wow = 0);
bool SetWinRegInt(int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE, dword wow = 0);
void DeleteWinReg(const String& key, HKEY base = HKEY_LOCAL_MACHINE, dword wow = 0);
this is backware compatible.
2 - in the functions bodys:
- GetWinRegString/GetWinRegInt : replace by
- SetWinRegString/SetWinRegExpandString/SetWinRegInt: replace by
- DeleteWinReg :
replace by
AND replace
by
if(wow)
RegDeleteKeyEx(base, key, wow, 0);
else
RegDeleteKey(base, key);
3 - Next, add a set of function to acees to specific part of the registry
3.1 : accees to the others part (the 32 part for 64 bin, or the 64 part for the 32 bin):
- define this macro WOW :
#ifdef CPU_64
#define WOW KEY_WOW64_32KEY
#else
#define WOW KEY_WOW64_64KEY
#endif
- Add the new functions,
String GetWinRegStringWOW ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return GetWinRegString ( value, path, base_key, WOW );
}
int GetWinRegIntWOW ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return GetWinRegInt ( value, path, base_key, WOW );
}
bool SetWinRegStringWOW ( const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return SetWinRegString ( string, value, path, base_key, WOW );
}
bool SetWinRegExpandStringWOW ( const String& string, const char *value, const char *path, HKEY base_key ){
return SetWinRegExpandString ( string, value, path, base_key, WOW );
}
bool SetWinRegIntWOW ( int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return SetWinRegInt ( string, value, path, base_key, WOW );
}
void DeleteWinRegWOW ( const String& key, HKEY base = HKEY_LOCAL_MACHINE ){
DeleteWinReg ( key, base, WOW );
}
3.2 : functions to accees to specific part:
64 bits:
String GetWinRegStringWOW64 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return GetWinRegString ( value, path, base_key, KEY_WOW64_64KEY );
}
int GetWinRegIntWOW64 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return GetWinRegInt ( value, path, base_key, KEY_WOW64_64KEY );
}
bool SetWinRegStringWOW64 ( const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return SetWinRegString ( string, value, path, base_key, KEY_WOW64_64KEY );
}
bool SetWinRegExpandStringWOW64 ( const String& string, const char *value, const char *path, HKEY base_key ){
return SetWinRegExpandString ( string, value, path, base_key, KEY_WOW64_64KEY );
}
bool SetWinRegIntWOW64 ( int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return SetWinRegInt ( string, value, path, base_key, KEY_WOW64_64KEY );
}
void DeleteWinRegWOW64 ( const String& key, HKEY base = HKEY_LOCAL_MACHINE ){
DeleteWinReg ( key, base, KEY_WOW64_64KEY );
}
and 32 bits:
String GetWinRegStringWOW32 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return GetWinRegString ( value, path, base_key, KEY_WOW64_32KEY );
}
int GetWinRegIntWOW32 ( const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return GetWinRegInt ( value, path, base_key, KEY_WOW64_32KEY );
}
bool SetWinRegStringWOW32 ( const String& string, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return SetWinRegString ( string, value, path, base_key, KEY_WOW64_32KEY );
}
bool SetWinRegExpandStringWOW32 ( const String& string, const char *value, const char *path, HKEY base_key ){
return SetWinRegExpandString ( string, value, path, base_key, KEY_WOW64_32KEY );
}
bool SetWinRegIntWOW32 ( int data, const char *value, const char *path, HKEY base_key = HKEY_LOCAL_MACHINE ){
return SetWinRegInt ( string, value, path, base_key, KEY_WOW64_32KEY );
}
void DeleteWinRegWOW32 ( const String& key, HKEY base = HKEY_LOCAL_MACHINE ){
DeleteWinReg ( key, base, KEY_WOW64_32KEY );
}
regards
omari.
[Updated on: Thu, 02 June 2016 19:08] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Sun May 11 11:53:13 CEST 2025
Total time taken to generate the page: 0.02589 seconds
|