summaryrefslogtreecommitdiff
path: root/default/default.c
blob: 5b75c6e3e79d0ae0e767ff31e4278fa3f1b0453b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}