rawaccel/uninstaller/uninstaller.cpp
a1xd c5987ac1e2 improve installer + docs
improve exception handling
add link to vcr redist in install section of guide
2020-10-07 05:31:23 -04:00

32 lines
1 KiB
C++

#include <iostream>
#include <utility-install.hpp>
int main() {
try {
modify_upper_filters([](std::vector<std::wstring>& filters) {
std::erase(filters, DRIVER_NAME);
});
fs::path target = get_target_path();
fs::path tmp = make_temp_path(target);
// schedule tmp to be deleted if rename target -> tmp is successful
if (MoveFileExW(target.c_str(), tmp.c_str(), MOVEFILE_REPLACE_EXISTING)) {
MoveFileExW(tmp.c_str(), NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
}
else { // tmp is in use and delete is already scheduled
if (fs::exists(target)) fs::remove(target);
}
std::cout << "Removal complete, change will take effect after restart.\n";
}
catch (const std::system_error& e) {
std::cerr << "Error: " << e.what() << ' ' << e.code() << '\n';
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << '\n';
}
std::cout << "Press any key to close this window . . .\n";
_getwch();
}