summaryrefslogtreecommitdiff
path: root/uninstaller/uninstaller.cpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-07-22 19:34:13 -0400
committera1xd <[email protected]>2020-07-22 19:34:13 -0400
commit78156f34166c110fcad47aef166684b8e25ac4fa (patch)
treeb6121a5e1725639800c266c865f9067b3cd31a17 /uninstaller/uninstaller.cpp
parentAdd .gitignore and .gitattributes. (diff)
downloadrawaccel-78156f34166c110fcad47aef166684b8e25ac4fa.tar.xz
rawaccel-78156f34166c110fcad47aef166684b8e25ac4fa.zip
Add project files.v0.1-test
Diffstat (limited to 'uninstaller/uninstaller.cpp')
-rw-r--r--uninstaller/uninstaller.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/uninstaller/uninstaller.cpp b/uninstaller/uninstaller.cpp
new file mode 100644
index 0000000..4d02715
--- /dev/null
+++ b/uninstaller/uninstaller.cpp
@@ -0,0 +1,29 @@
+#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 (std::exception e) {
+ std::cerr << "Error: " << e.what() << '\n';
+ }
+
+ std::cout << "Press any key to close this window . . .\n";
+ _getwch();
+}