aboutsummaryrefslogtreecommitdiff
path: root/src/main/oshelper.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-04-28 15:14:40 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-04-28 15:14:40 -0500
commit286c75aa5bb29bb54ea8b3b060e925ecfc3c6f69 (patch)
treeb9a5c1519f232da6e27e9a3c258a999200a5fe2b /src/main/oshelper.cpp
parent0a4d65dd99b6cf8973f30a32f70f298f52f6cbfe (diff)
parent9b98e0a2f5b28279fa4cbe37be44f4866360a17d (diff)
downloadmonzero-gui-286c75aa5bb29bb54ea8b3b060e925ecfc3c6f69.tar.gz
monzero-gui-286c75aa5bb29bb54ea8b3b060e925ecfc3c6f69.tar.xz
monzero-gui-286c75aa5bb29bb54ea8b3b060e925ecfc3c6f69.zip
Merge pull request #2850
9b98e0a checkUpates: installer support (Win), use GUI buildTag and version (xiphon)
Diffstat (limited to 'src/main/oshelper.cpp')
-rw-r--r--src/main/oshelper.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/oshelper.cpp b/src/main/oshelper.cpp
index 75c668f5..c4923f35 100644
--- a/src/main/oshelper.cpp
+++ b/src/main/oshelper.cpp
@@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "oshelper.h"
+#include <QCoreApplication>
#include <QFileDialog>
#include <QStandardPaths>
#include <QTemporaryFile>
@@ -164,3 +165,47 @@ QString OSHelper::temporaryPath() const
{
return QDir::tempPath();
}
+
+bool OSHelper::installed() const
+{
+#ifdef Q_OS_WIN
+ static constexpr const wchar_t installKey[] =
+ L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Monero GUI Wallet_is1";
+ static constexpr const wchar_t installValue[] = L"InstallLocation";
+
+ DWORD size;
+ LSTATUS status =
+ ::RegGetValueW(HKEY_LOCAL_MACHINE, installKey, installValue, RRF_RT_REG_SZ, nullptr, nullptr, &size);
+ if (status == ERROR_FILE_NOT_FOUND)
+ {
+ return false;
+ }
+ if (status != ERROR_SUCCESS)
+ {
+ qCritical() << "RegGetValueW failed (get size)" << status;
+ return false;
+ }
+
+ std::wstring installLocation;
+ installLocation.resize(size / sizeof(std::wstring::value_type));
+ size = installLocation.size() * sizeof(std::wstring::value_type);
+ status = ::RegGetValueW(
+ HKEY_LOCAL_MACHINE,
+ installKey,
+ installValue,
+ RRF_RT_REG_SZ,
+ nullptr,
+ &installLocation[0],
+ &size);
+ if (status != ERROR_SUCCESS)
+ {
+ qCritical() << "RegGetValueW Failed (read)" << status;
+ return false;
+ }
+
+ const QDir installDir(QString(reinterpret_cast<const QChar *>(&installLocation[0])));
+ return installDir == QDir(QCoreApplication::applicationDirPath());
+#else
+ return false;
+#endif
+}