Home > OS >  [question] how to use a nested path to access two different paths, specific please see detailed desc
[question] how to use a nested path to access two different paths, specific please see detailed desc

Time:10-04

Dear Daniel, my side when doing the project meet a problem:

A software to compatible with different systems of the two systems registry path is different, but the code requires a logical path to said, such as:

A system, the registry path:/SOFTWARE/WcndFn/Ulter
B system, the registry path:/SOFTWARE/Ulter

Actually a, b system registry path have sent level folder, a system level more WcndFn folder, but the code requires to a logical path to access these two different paths, are using the Windows API function RegOpenKeyEx, function is as follows:

LONG RegOpenKeyEx (
Hkeys hkeys,//the name of the need to open the primary key of the
LPCTSTR lpSubKey,//need to open the child key the name of the
DWORD ulOptions,//reserve, to 0
REGSAM samDesired,//security access tag, that is, permission
PHKEY phkResult//to get a handle to the open key
)

Originally program only needs to be run on a system, so the second RegOpenKeyEx parameters only need to "//SOFTWARE//WcndFn//Ulter" is ok, but now requires compatible program b system, not the original this way, the b on the system could not find the corresponding registry path, because the code is an absolute path, can only access the same path and a system registry,

Now thinking of the original "//SOFTWARE//WcndFn//Ulter" the string into a logical representation of the path, and then to RegOpenKeyEx, this can be found on a system/SOFTWARE/WcndFn/Ulter, and on b system/SOFTWARE/Ulter can be found,

How to construct the string ah, or how to construct such a path, can be compatible with both cases? Asked not to let in a way to distinguish the system into different path, can only use a logic path or a relative path,
Program is written in C/C + +, cannot use regular expressions, the system is of two kinds of different Windows system,
Give everyone a great god to a reasonable solution ~ ~ ~, on the Internet can't find a reasonable solution, T_T, ~ ~ thank you Daniel

CodePudding user response:

The variables in directly,
Prepare a set of global variables, two sets of values, the program runs, judge system version first, according to the different versions, one set of values

CodePudding user response:

reference 1/X - I - n reply:
pass variables directly into,
Prepare a set of global variables, two sets of values, the program runs after the first judgment system version, according to the different versions, one set of values assigned

How to judge the system?? Need to distinguish between windows2008 and windows2012, query the registry, but I am looking for information on the Internet can check different versions of the same system, or don't know how to distinguish between different systems

CodePudding user response:

Registries find HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion
Key ProductName value is Friendly Name, such as Windows 10 Enterprise, or Windows Server 2008 R2 Standard, according to the direct judgment operating system
Key CurrentVersion value is the kernel of plate number, such as 6.3, 6.1, according to this judgment operating system algebra
 
5.0 2000
5.1 XP
5.2 2003/2003 r2
6.0 vista/2008
6.1 Windows 7/2008 r2
6.2 doing/2012
6.3 win8.1/win10/2012 r2

Key CurrentBuild is Build plate number, such as 15063, according to the judgment operating system Patch plate number

CodePudding user response:

The
reference X - I - n reply: 3/f
registries find HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion
Key ProductName value is Friendly Name, such as Windows 10 Enterprise, or Windows Server 2008 R2 Standard, according to the direct judgment operating system
Key CurrentVersion value is the kernel of plate number, such as 6.3, 6.1, according to this judgment operating system algebra
 
5.0 2000
5.1 XP
5.2 2003/2003 r2
6.0 vista/2008
6.1 Windows 7/2008 r2
6.2 doing/2012
6.3 win8.1/win10/2012 r2

Key CurrentBuild is Build plate number, such as 15063, according to the judgment operating system Patch plate number

This scheme is feasible, you to write a path through the distinguish system, but the leadership think this plan is too complicated... , sad...

CodePudding user response:

This is a five or six lines of code? Registry value, do a the if judgment is complete,

CodePudding user response:

refer to fifth floor X - I - n reply:
this is five or six lines of code? Registry value, do a the if judgment is complete,

Uh uh uh... To make a lot of change point
  • Related