1 #include "../common/git-compat-util.h"
3 #include "../common/systeminfo.h"
6 static char gitPath
[MAX_PATH
] = "";
7 static TCHAR msysPath
[MAX_PATH
];
9 static int get_msys_path_from_registry(HKEY root
)
12 DWORD path_len
= sizeof(msysPath
);
14 LONG result
= RegOpenKeyEx(root
, GIT_CHEETAH_REG_PATH
,
15 0, KEY_QUERY_VALUE
, &key
);
16 if (ERROR_SUCCESS
!= result
)
19 result
= RegQueryValueEx(key
,
20 GIT_CHEETAH_REG_PATHTOMSYS
,
21 NULL
, NULL
, (LPBYTE
)msysPath
, &path_len
);
25 return ERROR_SUCCESS
== result
;
28 static TCHAR
*msys_path(void)
30 static int found_path
= 0;
32 /* try to find user-specific settings first */
34 found_path
= get_msys_path_from_registry(HKEY_CURRENT_USER
);
36 /* if not found in user settings, try machine-wide */
38 found_path
= get_msys_path_from_registry(HKEY_LOCAL_MACHINE
);
46 static inline int test_msys_path(const char *postfix
, char *path
)
49 char stat_path
[MAX_PATH
];
50 struct stat stat_info
;
52 n
= snprintf(stat_path
, MAX_PATH
, "%s\\%s\\git",
53 msys_path(), postfix
);
55 goto test_git_path_failed
;
57 n
= snprintf(path
, MAX_PATH
, "%s\\%s", msys_path(), postfix
);
59 goto test_git_path_failed
;
61 if (lstat(path
, &stat_info
) == 0) {
70 const char *git_path()
80 if (test_msys_path("bin", path
)) {
81 memcpy(gitPath
, path
, MAX_PATH
);
85 if (test_msys_path("mingw\\bin", path
)) {
86 memcpy(gitPath
, path
, MAX_PATH
);
93 void message_box(const char *string
)
95 MessageBox(0, string
, "Hello", MB_OK
|MB_ICONEXCLAMATION
);