Error: main.obj: -1: error: LNK2019: link to unresolved external symbol __imp__RegOpenKeyExW @ 20 in the _main function What could be wrong? MSVC2015 compiler 32, everything works on mingw, but I need the MSVC compiler here's the code:
#include "mainwindow.h" #include <QApplication> #include "shobjidl.h" #include "windows.h" #include <QStringList> #include <QDebug> enum HKEY_LIST { HK_CLASSES_ROOT=0x80000000, HK_CURRENT_USER=0x80000001, HK_LOCAL_MACHINE=0x80000002, HK_USERS=0x80000003, HK_PERFORMANCE_DATA=0x80000004, HK_CURRENT_CONFIG=0x80000005 }; int main(int argc, char *argv[]) { QApplication a(argc, argv); // QString myValue; HKEY hKey; LPCWSTR val=L"WallPaper"; LPCWSTR path=L"Control panel\\Desktop"; HKEY_LIST list =HKEY_LIST::HK_CURRENT_USER; if(RegOpenKeyEx((HKEY)list,path,0,KEY_READ,&hKey)==ERROR_SUCCESS) { DWORD dwSize = 512; wchar_t lszValue[512]; bool noError=RegQueryValueEx(hKey,val,NULL,NULL,(LPBYTE)lszValue,&dwSize)==ERROR_SUCCESS; //RegCloseKey(hKey); if(noError) { QString outp = QString::fromWCharArray(lszValue); qDebug() <<"outp=" <<outp; } } MainWindow w; w.show(); return a.exec(); } 


advapi32.libto the list of libraries (Linker> Input> Additional Dependencies). - ߊߚߤߘ