add version checker and messagebox to let user proceed even on non-xp machines
This commit is contained in:
@@ -60,7 +60,7 @@ $(TARGET): $(OBJ_C) $(OBJ_CPP) $(OBJ_RC)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Compile C++ sources
|
||||
%.o: %.cc
|
||||
%.o: %.cc $(HEADERS)
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
# Compile .rc → .o or .res
|
||||
|
||||
@@ -28,4 +28,6 @@ static const IID licenseAgentIID = {0xB8CBAD79, 0x3F1F, 0x481A, {0xBB, 0x0C, 0xE
|
||||
//IID for ICOMLicenseAgent2, with three extra functions
|
||||
static const IID licenseAgentIID2 = {0x6A07C5A3, 0x9C67, 0x4BB6, {0xB0, 0x20, 0xEC, 0xBE, 0x7F, 0xDF, 0xD3, 0x26}};
|
||||
|
||||
const LPCWSTR XP_MISMATCH = L"It seems you are not running Windows XP, \nwould you like to run the program anyway \nin debug mode for testing?)";
|
||||
|
||||
#endif // XP_ACTIVATE32_CONSTANTS_H_
|
||||
|
||||
+7
-2
@@ -444,8 +444,13 @@ std::wstring const GetOSNameW() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::wstring const GetWinVersion() {
|
||||
const std::wstring wver = stringToWstring(GetNTString());
|
||||
std::string const GetWinVersionA() {
|
||||
const std::string ver = GetNTString();
|
||||
return ver;
|
||||
}
|
||||
|
||||
std::wstring const GetWinVersionW() {
|
||||
const std::wstring wver = stringToWstring(GetWinVersionA());
|
||||
return wver;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -54,8 +54,11 @@ std::string const GetOSNameA();
|
||||
|
||||
std::wstring const GetOSNameW();
|
||||
|
||||
std::wstring const GetWinVersion();
|
||||
std::string const GetWinVersionA();
|
||||
|
||||
std::wstring const GetWinVersionW();
|
||||
|
||||
// TODO convert to class and private
|
||||
std::string const GetNTString();
|
||||
|
||||
// Debug functions
|
||||
|
||||
+41
-9
@@ -1042,6 +1042,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
/* Assign global HINSTANCE */
|
||||
g_hInstance = hInstance;
|
||||
int return_code;
|
||||
bool open_main_dialog = false;
|
||||
//MSG Msg;
|
||||
long err_status;
|
||||
|
||||
@@ -1077,15 +1079,41 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
std::wstring welcome_str = L"Welcome to XP_Activate32 ver. " + getVersionW();
|
||||
std::wcout << welcome_str << std::endl;
|
||||
std::wcout << L"Windows Version: " << GetOSNameW() << std::endl;
|
||||
std::wcout << L"GetWinVersion() = " << GetWinVersion() << std::endl;
|
||||
std::cout << "WinVer: " << WinVer << std::endl;
|
||||
std::wcout << L"NT Version = " << GetWinVersionW() << std::endl;
|
||||
|
||||
// Create main window
|
||||
INT_PTR main_dialog = DialogBoxW(g_hInstance, MAKEINTRESOURCE(100), NULL, &DialogProc);
|
||||
err_status = static_cast<long>(main_dialog);
|
||||
constexpr float xp_ntver = 5.1f;
|
||||
constexpr float xp64_ntver = 5.2f;
|
||||
if (WinVer != xp_ntver && WinVer != xp64_ntver) {
|
||||
int user_response_code;
|
||||
user_response_code =
|
||||
MessageBoxW(nullptr, XP_MISMATCH, L"Windows Version Mismatch!",
|
||||
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1);
|
||||
if (user_response_code == IDNO) {
|
||||
std::wcout << L"User declined, exiting..." << std::endl;
|
||||
return_code = 0;
|
||||
} else if (user_response_code == IDCANCEL) {
|
||||
std::wcout << L"User declined, exiting..." << std::endl;
|
||||
return_code = 0;
|
||||
} else if (user_response_code == IDYES) {
|
||||
return_code = 69;
|
||||
open_main_dialog = true;
|
||||
} else {
|
||||
return_code = 2;
|
||||
}
|
||||
} else {
|
||||
open_main_dialog = true;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
DestroyIcon(hIcon[i]);
|
||||
if (open_main_dialog) {
|
||||
// Create main window
|
||||
INT_PTR main_dialog = DialogBoxW(g_hInstance, MAKEINTRESOURCE(100), NULL, &DialogProc);
|
||||
err_status = static_cast<long>(main_dialog);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
DestroyIcon(hIcon[i]);
|
||||
}
|
||||
} else {
|
||||
err_status = 0L;
|
||||
}
|
||||
|
||||
if (LicenseAgent) {
|
||||
@@ -1097,8 +1125,12 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||
}
|
||||
|
||||
std::wcout << L"err_status = " << err_status << std::endl;
|
||||
if (err_status != 0L) {
|
||||
|
||||
if (err_status == 0L) {
|
||||
return_code = 0;
|
||||
return return_code;
|
||||
} else {
|
||||
system("pause");
|
||||
ExitProcess(err_status);
|
||||
}
|
||||
ExitProcess(err_status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user