VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-09-26 01:22:24 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-09-26 01:22:24 +0200
commit662b8d1b2fd37cac35c2c48539e846c93ad17f7d (patch)
treece60b517753c63e1923e3df148876c3bec0f0032
parent4cb4ec35007bace54e81b6dd0202bbb3705f4b65 (diff)
downloadVeraCrypt-662b8d1b2fd37cac35c2c48539e846c93ad17f7d.tar.gz
VeraCrypt-662b8d1b2fd37cac35c2c48539e846c93ad17f7d.zip
Windows: during Setup, and if VeraCrypt already installed, open online help only if PC connected to Internet
-rw-r--r--src/Common/Dlgcode.c42
-rw-r--r--src/Common/Dlgcode.h1
2 files changed, 40 insertions, 3 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index d9bb776e..2fede6fe 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -18,6 +18,7 @@
#include <dbt.h>
#include <Setupapi.h>
#include <aclapi.h>
+#include <Netlistmgr.h>
#include <fcntl.h>
#include <io.h>
#include <math.h>
@@ -11223,10 +11224,18 @@ void Applink (const char *dest)
if (buildUrl)
{
- // in case of setup, always open the online documentation because existing documentation may be outdated
+ // in case of setup, open the online documentation if we are connected to Internet because existing documentation may be outdated
#ifdef SETUP
- StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
- buildUrl = FALSE;
+ if (IsInternetConnected())
+ {
+ StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
+ buildUrl = FALSE;
+ }
+ else
+ {
+ StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
+ CorrectURL (url);
+ }
#else
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
CorrectURL (url);
@@ -15233,6 +15242,33 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format)
}
+// check if the PC is connected to the internet using INetworkListManager interface
+BOOL IsInternetConnected()
+{
+ HRESULT hr;
+ BOOL isConnected = FALSE;
+ INetworkListManager* pNetworkListManager = nullptr;
+
+ hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+ if (SUCCEEDED(hr))
+ {
+ hr = CoCreateInstance(CLSID_NetworkListManager, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pNetworkListManager));
+ if (SUCCEEDED(hr))
+ {
+ VARIANT_BOOL isConnectedVariant;
+ hr = pNetworkListManager->get_IsConnectedToInternet(&isConnectedVariant);
+ if (SUCCEEDED(hr))
+ {
+ isConnected = isConnectedVariant == VARIANT_TRUE;
+ }
+ pNetworkListManager->Release();
+ }
+ CoUninitialize();
+ }
+
+ return isConnected;
+}
+
/*
* Query the status of Hibernate and Fast Startup
*/
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 3611371d..750b4dc7 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -597,6 +597,7 @@ DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize);
#ifdef _WIN64
void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed);
#endif
+BOOL IsInternetConnected();
#ifdef __cplusplus
}