From a2a87bb37386b8eeff3484517c91ba907f1a7780 Mon Sep 17 00:00:00 2001 From: lllucius Date: Sat, 5 Mar 2011 06:31:02 +0000 Subject: [PATCH] Correct bug 142 This changes the way Audacity searches for VST plugins on Windows. Searching now follows the order specified here: http://wiki.audacityteam.org/index.php?title=VST_Plug-ins#Where_Audacity_looks_for_VST_plug-ins --- src/effects/VST/VSTEffect.cpp | 49 ++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index ee7e27342..551d8e488 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -1718,28 +1718,47 @@ void VSTEffect::Scan() #elif defined(__WXMSW__) TCHAR dpath[MAX_PATH]; TCHAR tpath[MAX_PATH]; - DWORD len = WXSIZEOF(tpath); + DWORD len; - // Setup the default VST path. - dpath[0] = '\0'; - ExpandEnvironmentStrings(wxT("%ProgramFiles%\\Steinberg\\VSTPlugins"), - dpath, - WXSIZEOF(dpath)); - - // Check registry for the real path + // Try HKEY_CURRENT_USER registry key first + len = sizeof(tpath) / sizeof(TCHAR); if (SHRegGetUSValue(wxT("Software\\VST"), - wxT("VSTPluginsPath"), - NULL, - tpath, - &len, - FALSE, - dpath, - (DWORD) _tcslen(dpath)) == ERROR_SUCCESS) { + wxT("VSTPluginsPath"), + NULL, + tpath, + &len, + FALSE, + NULL, + 0) == ERROR_SUCCESS) { tpath[len] = 0; + dpath[0] = 0; ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath)); wxGetApp().AddUniquePathToPathList(LAT1CTOWX(dpath), pathList); } + // Then try HKEY_LOCAL_MACHINE registry key + len = sizeof(tpath) / sizeof(TCHAR); + if (SHRegGetUSValue(wxT("Software\\VST"), + wxT("VSTPluginsPath"), + NULL, + tpath, + &len, + TRUE, + NULL, + 0) == ERROR_SUCCESS) { + tpath[len] = 0; + dpath[0] = 0; + ExpandEnvironmentStrings(tpath, dpath, WXSIZEOF(dpath)); + wxGetApp().AddUniquePathToPathList(LAT1CTOWX(dpath), pathList); + } + + // Add the default path last + dpath[0] = 0; + ExpandEnvironmentStrings(wxT("%ProgramFiles%\\Steinberg\\VSTPlugins"), + dpath, + WXSIZEOF(dpath)); + wxGetApp().AddUniquePathToPathList(LAT1CTOWX(dpath), pathList); + // Recursively scan for all DLLs wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files, wxDIR_DEFAULT);