Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
add internet connection check
Browse files Browse the repository at this point in the history
  • Loading branch information
mq1n committed Jun 27, 2021
1 parent 647eb2d commit 5284ea8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ add_executable (${PROJECT_NAME}
src/main.cpp
)

target_link_libraries(${PROJECT_NAME} PowrProf Tbs)
target_link_libraries(${PROJECT_NAME} PowrProf WinInet Tbs)
24 changes: 24 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Windows.h>
#include <powerbase.h>
#include <WinInet.h>
#include <tbs.h>
#include <intrin.h>
#include <string>
Expand Down Expand Up @@ -503,6 +504,29 @@ int main(int, char* argv[])
std::cout << "WDDM check passed!" << std::endl;
}

// Internet connection
{
std::cout << "Internet connection checking..." << std::endl;

DWORD dwFlags = 0;
if (!InternetGetConnectedState(&dwFlags, 0))
{
std::cerr << "InternetGetConnectedState failed with error: " << GetLastError() << std::endl;
std::system("PAUSE");
return EXIT_FAILURE;
}

const auto dwTestConnectionRet = InternetAttemptConnect(0);
if (dwTestConnectionRet != ERROR_SUCCESS)
{
std::cerr << "InternetAttemptConnect failed with error: " << GetLastError() << std::endl;
std::system("PAUSE");
return EXIT_FAILURE;
}

std::cout << "Internet connection check passed!" << std::endl;
}

std::cout << "All checks passed! Your system can be upgradable to Windows 11" << std::endl;
std::system("PAUSE");
return EXIT_SUCCESS;
Expand Down

0 comments on commit 5284ea8

Please sign in to comment.