P/Invoke uses LoadLibrary to load DLLs, and if there is already a library loaded with a given name, LoadLibrary will return it. So if you can give both versions of the DLL the same name, but put them in different directories, you can do something like this just once before your first call to a function from scilexer.dll, without needing to duplicate your extern declarations:
string platform = IntPtr.Size == 4 ? "x86" : "x64";
string dll = installDir + @"lib-" + platform + @"scilexer.dll";
if (LoadLibrary(dll) == IntPtr.Zero)
throw new IOException("Unable to load " + dll + ".");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…