summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2011-10-30 11:01:00 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2011-10-30 11:01:00 +0000
commit1e74ef639d9d6701d732ee61164f84cf2f660a09 (patch)
tree89e08c92cba561763e333df103ce7d44ebae2099
parent6f716e905590fa7c1b759250bcbbcd2f7104a4f6 (diff)
downloadrockbox-1e74ef639d9d6701d732ee61164f84cf2f660a09.tar.gz
rockbox-1e74ef639d9d6701d732ee61164f84cf2f660a09.zip
beastpatcher: check WMP version.
The current implementation fails silently if Windows Media Player is version 10. Add a check and inform the user if the version installed is too old to work properly with beastpatcher. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30864 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/MTP/beastpatcher/main.c7
-rw-r--r--utils/MTP/beastpatcher/mtp_common.h4
-rw-r--r--utils/MTP/beastpatcher/mtp_win32.c42
3 files changed, 53 insertions, 0 deletions
diff --git a/utils/MTP/beastpatcher/main.c b/utils/MTP/beastpatcher/main.c
index 97d931e454..219433456b 100644
--- a/utils/MTP/beastpatcher/main.c
+++ b/utils/MTP/beastpatcher/main.c
@@ -104,6 +104,13 @@ int main(int argc, char* argv[])
104 if(argc > 1) { 104 if(argc > 1) {
105 interactive = 0; 105 interactive = 0;
106 } 106 }
107#if defined(__WIN32__) || defined(_WIN32)
108 if(mtp_wmp_version() < 11) {
109 fprintf(stderr, "beastpacher requires at least Windows Media Player 11 to run!\n");
110 fprintf(stderr, "Please update you installation of Windows Media Player.\n");
111 return -1;
112 }
113#endif
107 114
108 i = 1; 115 i = 1;
109 while(i < argc) { 116 while(i < argc) {
diff --git a/utils/MTP/beastpatcher/mtp_common.h b/utils/MTP/beastpatcher/mtp_common.h
index 2ca87c7509..8cd261416c 100644
--- a/utils/MTP/beastpatcher/mtp_common.h
+++ b/utils/MTP/beastpatcher/mtp_common.h
@@ -59,6 +59,10 @@ struct mtp_info_t
59#endif 59#endif
60}; 60};
61 61
62#if defined(__WIN32__) || defined(_WIN32)
63int mtp_wmp_version(void);
64#endif
65
62/* Common functions for both libMTP and win32 */ 66/* Common functions for both libMTP and win32 */
63 67
64int mtp_init(struct mtp_info_t* mtp_info); 68int mtp_init(struct mtp_info_t* mtp_info);
diff --git a/utils/MTP/beastpatcher/mtp_win32.c b/utils/MTP/beastpatcher/mtp_win32.c
index 15d0d705e2..626467ecbe 100644
--- a/utils/MTP/beastpatcher/mtp_win32.c
+++ b/utils/MTP/beastpatcher/mtp_win32.c
@@ -230,3 +230,45 @@ static int filesize(const char* filename)
230 return sb.st_size; 230 return sb.st_size;
231} 231}
232 232
233/* Retrieve version of WMP as described in
234 * http://msdn.microsoft.com/en-us/library/dd562731%28VS.85%29.aspx
235 * Since we're after MTP support checking for the WMP6 key is not necessary.
236 */
237int mtp_wmp_version(void)
238{
239 DWORD ret;
240 HKEY hk;
241 DWORD type;
242 DWORD enable = -1;
243 DWORD enablelen = sizeof(DWORD);
244 char buf[32];
245 DWORD buflen = sizeof(buf);
246 int version = 0;
247
248 ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
249 "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\{6BF52A52-394A-11d3-B153-00C04F79FAA6}",
250 0, KEY_QUERY_VALUE, &hk);
251
252 if(ret != ERROR_SUCCESS) {
253 return 0;
254 }
255 type = REG_DWORD;
256 ret = RegQueryValueExA(hk, "IsInstalled", NULL, &type, (LPBYTE)&enable, &enablelen);
257 if(ret != ERROR_SUCCESS) {
258 RegCloseKey(hk);
259 return 0;
260 }
261 if(enable) {
262 type = REG_SZ;
263 ret = RegQueryValueExA(hk, "Version", NULL, &type, (LPBYTE)buf, &buflen);
264 }
265 if(ret == ERROR_SUCCESS) {
266 /* get major version from registry value */
267 buf[31] = '\0';
268 version = atoi(buf);
269 }
270 RegCloseKey(hk);
271
272 return version;
273}
274