From 584c4446b5f75baa70400c7401d300870d49b8bb Mon Sep 17 00:00:00 2001 From: mickael9 Date: Wed, 28 Dec 2011 22:42:51 +0100 Subject: [PATCH] Use AssocQueryString on Windows for script resolvers that are not .exe files (untested !) --- src/libtomahawk/resolvers/scriptresolver.cpp | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/resolvers/scriptresolver.cpp b/src/libtomahawk/resolvers/scriptresolver.cpp index b452c7b56..37fd4ec05 100644 --- a/src/libtomahawk/resolvers/scriptresolver.cpp +++ b/src/libtomahawk/resolvers/scriptresolver.cpp @@ -30,6 +30,9 @@ #include "utils/tomahawkutils.h" #include "utils/logger.h" +#ifdef Q_OS_WIN +#include +#endif ScriptResolver::ScriptResolver( const QString& exe ) : Tomahawk::ExternalResolverGui( exe ) @@ -377,9 +380,26 @@ void ScriptResolver::startProcess() QString runPath = filePath(); #ifdef Q_OS_WIN - if(fi.completeSuffix() == "py") + if ( fi.suffix().toLower() != "exe" ) { - interpreter = "python.exe"; + DWORD dwSize = MAX_PATH; + + wchar_t path[MAX_PATH] = { 0 }; + wchar_t *ext = (wchar_t *) ("." + fi.suffix()).utf16(); + + HRESULT hr = AssocQueryStringW( + (ASSOCF) 0, + ASSOCSTR_EXECUTABLE, + ext, + L"open", + path, + &dwSize + ); + + if ( ! FAILED( hr ) ) + { + interpreter = QString( "\"%1\"" ).arg(QString::fromUtf16((const ushort *) path)); + } } else {