diff options
author | John Ankarström <john@ankarstrom.se> | 2020-11-03 13:28:05 +0100 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2020-11-20 15:17:34 +0100 |
commit | 0df815469658a0df4218f131041a9037991db388 (patch) | |
tree | 239aae9866f9273d703e41ee95104df316ecea5e | |
download | windows-0df815469658a0df4218f131041a9037991db388.tar.gz |
Add 'default' tool
The default program can be used to quickly set the default browser, at
least on Windows XP.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | default/default.c | 31 | ||||
-rw-r--r-- | default/default.exe | bin | 0 -> 54272 bytes | |||
-rw-r--r-- | default/reg/chrome.reg | bin | 0 -> 6910 bytes | |||
-rw-r--r-- | default/reg/mypal.reg | bin | 0 -> 4768 bytes |
5 files changed, 32 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..281748d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.obj
\ No newline at end of file diff --git a/default/default.c b/default/default.c new file mode 100644 index 0000000..5b75c6e --- /dev/null +++ b/default/default.c @@ -0,0 +1,31 @@ +#include <shlobj.h> +#include <stdio.h> +#include <windows.h> + +#pragma comment(lib, "Shell32.lib") + +int main(int argc, char *argv[]) { + char cmd[500], path[500], *p; + int r; + + if (argc != 2) { + fprintf(stderr, "usage: %s browser\n", argv[0]); + return 1; + } + + r = GetModuleFileNameA(NULL, path, 500); + if (r == 0 || r == 500) { + fprintf(stderr, "Could not get path of executable (%d).\n", GetLastError()); + return 1; + } + + p = path + strlen(path) - 1; + while (*p != '\\') p--; + *p = '\0'; + + sprintf(cmd, "reg import \"%s\\reg\\%s.reg\"", path, argv[1]); + r = system(cmd); + if (r == 0) + SHChangeNotify(SHCNE_ASSOCCHANGED, 0, 0, 0); + return r; +}
\ No newline at end of file diff --git a/default/default.exe b/default/default.exe Binary files differnew file mode 100644 index 0000000..79040dd --- /dev/null +++ b/default/default.exe diff --git a/default/reg/chrome.reg b/default/reg/chrome.reg Binary files differnew file mode 100644 index 0000000..8c00c8b --- /dev/null +++ b/default/reg/chrome.reg diff --git a/default/reg/mypal.reg b/default/reg/mypal.reg Binary files differnew file mode 100644 index 0000000..bcafc08 --- /dev/null +++ b/default/reg/mypal.reg |