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[]) if(argc > 1) { interactive = 0; } +#if defined(__WIN32__) || defined(_WIN32) + if(mtp_wmp_version() < 11) { + fprintf(stderr, "beastpacher requires at least Windows Media Player 11 to run!\n"); + fprintf(stderr, "Please update you installation of Windows Media Player.\n"); + return -1; + } +#endif i = 1; 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 #endif }; +#if defined(__WIN32__) || defined(_WIN32) +int mtp_wmp_version(void); +#endif + /* Common functions for both libMTP and win32 */ int 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) return sb.st_size; } +/* Retrieve version of WMP as described in + * http://msdn.microsoft.com/en-us/library/dd562731%28VS.85%29.aspx + * Since we're after MTP support checking for the WMP6 key is not necessary. + */ +int mtp_wmp_version(void) +{ + DWORD ret; + HKEY hk; + DWORD type; + DWORD enable = -1; + DWORD enablelen = sizeof(DWORD); + char buf[32]; + DWORD buflen = sizeof(buf); + int version = 0; + + ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Active Setup\\Installed Components\\{6BF52A52-394A-11d3-B153-00C04F79FAA6}", + 0, KEY_QUERY_VALUE, &hk); + + if(ret != ERROR_SUCCESS) { + return 0; + } + type = REG_DWORD; + ret = RegQueryValueExA(hk, "IsInstalled", NULL, &type, (LPBYTE)&enable, &enablelen); + if(ret != ERROR_SUCCESS) { + RegCloseKey(hk); + return 0; + } + if(enable) { + type = REG_SZ; + ret = RegQueryValueExA(hk, "Version", NULL, &type, (LPBYTE)buf, &buflen); + } + if(ret == ERROR_SUCCESS) { + /* get major version from registry value */ + buf[31] = '\0'; + version = atoi(buf); + } + RegCloseKey(hk); + + return version; +} +