I use LoadLibraryA from my program to load orbiter.exe, VSOP87.dll and earth.dll (in that order).
Since I wrote a (standalone) trajectory planning tool, I'm trying to find a generic way to load the celbody dll and the atmospheric model dll ("generic" in the sense that the method should be good to load any celbody and atmospheric dll that Orbiter can load).
I think you just have to set the DLL path, and then just let Earth.dll load VSOP87.dll by itself. I think if you load VSOP, then Earth will try to load it, but its already loaded, which might lead to the access error.
As VSOP is in ORBITER_ROOT/Modules, afaik you would set the DLL directory to that, then load Earth.dll from that path.
Code:
SetDLLDirectory(".//Modules");
LoadLibrary("Celbody/Earth.dll");
The above is untested, I'm not sure if you can use relative paths that way. But the idea is the same. Set the DLL directory to ORBITER_ROOT/Modules, then load Earth.dll from the new DLL search path inside Modules.
That way, when Earth.dll calls
Code:
LoadLibrary("VSOP87.dll")
it finds VSOP, because the DLL search directory is just set to modules.