Qt5 solves the problem of reading the Windows system registry and cannot read the key value with the "\" key

Recently encountered a problem, that is

Such a registry entry, in QT, can read the key on the left side of the registry, but cannot get the value on the right side,

Found someone who had the same problem before: http://www.qtcn.org/bbs/read-htm-tid-55782.html

其实,这个东西Qt的文档中说的很明确:
Note that the backslash character is, as mentioned, used by QSettings to separate subkeys. As a result, you cannot read or write windows registry entries that contain slashes or backslashes; you should use a native windows API if you need to do so.

In this case, you need to call the windows API in QT to solve it.

(1) Add the static libraries and header files required by the windows API to operate the registry in QT

In the project pro file add:

LIBS += -lAdvapi32

add header file

#include <qt_windows.h>

(2)

 

References:

When using Windows registration functions such as RegOpenKeyEx, the compilation cannot resolve the problem  https://blog.csdn.net/linuxsmallping/article/details/51722648

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970832&siteId=291194637