I'm trying to make a program that saves information about a given VST plugin to a file, in order to assist with categorisation of VST plugins. I found a simple host for loading each plugin in Windows, but I can't seem to write to files from the host program once a plugin's editor window has been opened.
For the VST host, I'm using this code from GitHub:
https://gist.github.com/t-mat/206e3e7dfc3f89421bc1
I have also tried writing my own host by following this tutorial, and I encountered the same issue.
Here is the test code I'm using to try and write to a file (replaces the main() function in the GitHub link above):
int main() {
VstPlugin vstPlugin{ L"C:\\VSTNameHere.dll", GetConsoleWindow() };
std::cout << "Saving file...";
std::ofstream myfile;
myfile.open("test.txt");
myfile << "Test output.\n";
myfile.close();
}
If I comment out the vstPlugin
instantiation, the file saves. When I leave it in, however, I only see the 'Saving file...' message in the console and no file is created.
At this point I've narrowed down which section of the VST plugin initialisation is stopping files from saving, as it works when I remove the code that gets the editor window handle provided by the plugin and creates a window:
dispatcher(effEditOpen, 0, 0, editorHwnd);
RECT rc{};
ERect* erc = nullptr;
dispatcher(effEditGetRect, 0, 0, &erc);
rc.left = erc->left;
rc.top = erc->top;
rc.right = erc->right;
rc.bottom = erc->bottom;
resizeEditor(rc);
ShowWindow(editorHwnd, SW_SHOW);
If I was just storing information returned by the plugin (for example, the value of effFlagsHasEditor
or effFlagsIsSynth
) then removing this code wouldn't be a problem, but I'd like to be able to open the editor window as well so I can save a screenshot of it. Why won't files save once the editor window has been opened?