I need to make a call like this
RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\MICROSOFT\\Windows NT\\CurrentVersion"), 0, KEY_READ | KEY_WOW64_64KEY, &m_hRegKey)
but instead of
TEXT("SOFTWARE\\MICROSOFT\\Windows NT\\CurrentVersion")
i have only a qstring
i already tried
QString key = settings.fileName() + settings.group();
RegOpenKeyEx(HKEY_LOCAL_MACHINE, key.toStdString().c_str(), 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
but i get:
x.cpp:97: Fehler: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'LONG RegOpenKeyExW(HKEY, LPCWSTR, DWORD, REGSAM, PHKEY)'
RegOpenKeyEx(HKEY_LOCAL_MACHINE, key.toStdString().c_str(), 0, KEY_READ | KEY_WOW64_64KEY, &hkey);
i need the RegOpenKeyEx because i need to read binary values from the registry
You were close : QString has a toStdWString() function, which returns a std::wstring
instead of the std::string
returned by toStdString().
Then, call c_str() to get a const wchar_t*
.