DISTRHO / Cardinal

Virtual modular synthesizer plugin
https://cardinal.kx.studio/
GNU General Public License v3.0
2.22k stars 154 forks source link

Windows installer is copying files to three locations, but not finding the installed files. #202

Closed wpostma closed 2 years ago

wpostma commented 2 years ago

Expectation: Can run the installer and then use the VST2 plugin.

Actual experience:

Have to manually copy files from c:\Program Files\Common Files\Cardinal to the VST2 folder where the vst2 dll is to make the Cardinal plugin register and load, and operate.

I believe that when the installer was added, there may have been code added to find the files in c:\Program Files\Common Files\Cardinal however it is not finding the files, and it is acting like they were not installed.

falkTX commented 2 years ago

Have to manually copy files from c:\Program Files\Common Files\Cardinal to the VST2 folder where the vst2 dll is to make the Cardinal plugin register and load, and operate.

otherwise what happens? what is the error?

wpostma commented 2 years ago

The error depends on the host:

  1. Cantablile crashes.
  2. Bitwig ignores the plugin and acts like it's not installed (bitwig standard behaviour).
  3. I am going to try it next in carla and get logs
wpostma commented 2 years ago

It appears to be due to the code relying on environment variables, I suspect that a more robust mechanism to determine the asset folder is to call SHGetFolderPath with the correct CSIDL constant

https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetfolderpatha

wpostma commented 2 years ago
  1. works in Carla
  2. crashes cantabile
  3. crashes cubase 11
  4. crashes in bitwig 4.1

Probably works whenever the environment variable CommonProgramFiles exists.

Many win32 processes may be created without environment variable inheritance, inside the DAWs

wpostma commented 2 years ago

Okay I brushed off my stale C++ "interview question" skills and whipped up this which should work even if you have Unicode characters (chinese anyone?) in the system NTFS paths.

` // it's a bit harder than I thought to call an API and output it to the console in Windows.

#include <iostream>

extern "C" {

#include <Windows.h>
#include <Shlobj.h>

#include <fileapi.h>
#include <stringapiset.h>

}

#ifndef UNICODE  
#error ""this test should be done in unicode"
#endif

#define UTF8 

int main()
{
    TCHAR szProgramFilesCommon[MAX_PATH];
    SetConsoleOutputCP(CP_UTF8);

    szProgramFilesCommon[0] = '\0';
    SHGetFolderPath(HWND(0), CSIDL_PROGRAM_FILES_COMMON, NULL, 0, szProgramFilesCommon);
    size_t convertArrayLen = wcslen(szProgramFilesCommon)+1; // include the nul in the conversion

    // String s = String(  & szProgramFilesCommon[0] );

    CHAR mbcs[MAX_PATH * 4];

    BOOL defaultCH = false;

    WideCharToMultiByte(CP_UTF8, 0, szProgramFilesCommon, convertArrayLen, mbcs,MAX_PATH,NULL,&defaultCH );
    std::string s = std::string(mbcs);

std::cout << "assets " << s << std::flush; // wow I think this is a stupid way to code output. nice work bjarne.

}

`