VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
}