aboutsummaryrefslogtreecommitdiffstats
path: root/wizard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'wizard.cpp')
-rw-r--r--wizard.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/wizard.cpp b/wizard.cpp
index 5921cda..9f7d590 100644
--- a/wizard.cpp
+++ b/wizard.cpp
@@ -22,6 +22,10 @@
#include "wizard.h"
+#ifdef Q_OS_WIN
+#include "windows.h"
+#endif
+
Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
: QWizard(parent)
{
@@ -320,12 +324,20 @@ QString ImportFromGnupgPage::getGnuPGHome()
{
QString gnuPGHome="";
#ifdef _WIN32
+ bool existsAndSuccess = false;
+
+ HKEY hKey;
+
+ existsAndSuccess = (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\GNU\\GNUPG", 0, KEY_READ, &hKey) == ERROR_SUCCESS);
+
+ if (existsAndSuccess) {
QSettings gnuPGsettings("HKEY_CURRENT_USER\\Software\\GNU\\GNUPG", QSettings::NativeFormat);
- gnuPGHome = gnuPGsettings.value("HomeDir").toString();
- if (gnuPGHome.isEmpty()) {
- return NULL;
+ if (gnuPGsettings.contains("HomeDir")) {
+ gnuPGHome = gnuPGsettings.value("HomeDir").toString();
+ } else {
+ return NULL;
+ }
}
-
#else
gnuPGHome=QDir::homePath()+"/.gnupg";
if (! QFile(gnuPGHome).exists()) {