diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-09-01 20:56:10 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-09-01 20:56:10 +0000 |
commit | f00dd7c3ead156ce369c709518eb16c3bb6db3be (patch) | |
tree | f2223974849f5895476fc3b17a641a806bffb589 | |
parent | branch 0.3.2-1 (diff) | |
download | gpg4usb-f00dd7c3ead156ce369c709518eb16c3bb6db3be.tar.gz gpg4usb-f00dd7c3ead156ce369c709518eb16c3bb6db3be.zip |
fix creation of windows registry key on import from GnuPG, if gnupg key doesn't already exist
(r913)
git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.3.2-1@945 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | wizard.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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()) { |