Add context-sensitive Git History item
[git-cheetah/kirill.git] / systeminfo.c
blob1c5acfabe7df1e2fedc2aa79bb3974979a48f5fb
1 #include <windows.h>
2 #include "systeminfo.h"
4 static TCHAR msysPath[MAX_PATH];
6 static int get_msys_path_from_registry(HKEY root)
8 HKEY key;
9 DWORD path_len = sizeof(msysPath);
11 LONG result = RegOpenKeyEx(root, GIT_CHEETAH_REG_PATH,
12 0, KEY_QUERY_VALUE, &key);
13 if (ERROR_SUCCESS != result)
14 return 0;
16 result = RegQueryValueEx(key,
17 GIT_CHEETAH_REG_PATHTOMSYS,
18 NULL, NULL, (LPBYTE)msysPath, &path_len);
20 RegCloseKey(key);
22 return ERROR_SUCCESS == result;
25 TCHAR *msys_path(void)
27 static int found_path = 0;
29 /* try to find user-specific settings first */
30 if (!found_path)
31 found_path = get_msys_path_from_registry(HKEY_CURRENT_USER);
33 /* if not found in user settings, try machine-wide */
34 if (!found_path)
35 found_path = get_msys_path_from_registry(HKEY_LOCAL_MACHINE);
37 if (found_path)
38 return msysPath;
40 return NULL;