Windows: during Setup, and if VeraCrypt already installed, open online help only if PC connected to Internet

This commit is contained in:
Mounir IDRASSI 2023-09-26 01:22:24 +02:00
parent 4cb4ec3500
commit 662b8d1b2f
No known key found for this signature in database
GPG Key ID: FC1B00364B3FE937
2 changed files with 40 additions and 3 deletions

View File

@ -18,6 +18,7 @@
#include <dbt.h> #include <dbt.h>
#include <Setupapi.h> #include <Setupapi.h>
#include <aclapi.h> #include <aclapi.h>
#include <Netlistmgr.h>
#include <fcntl.h> #include <fcntl.h>
#include <io.h> #include <io.h>
#include <math.h> #include <math.h>
@ -11223,10 +11224,18 @@ void Applink (const char *dest)
if (buildUrl) 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 #ifdef SETUP
if (IsInternetConnected())
{
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page); StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
buildUrl = FALSE; buildUrl = FALSE;
}
else
{
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
CorrectURL (url);
}
#else #else
StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page); StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page);
CorrectURL (url); 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 * Query the status of Hibernate and Fast Startup
*/ */

View File

@ -597,6 +597,7 @@ DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize);
#ifdef _WIN64 #ifdef _WIN64
void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed); void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed);
#endif #endif
BOOL IsInternetConnected();
#ifdef __cplusplus #ifdef __cplusplus
} }