Search code examples
c++dllshadow-copy

Use two different versions of a .lib file in one C++ project?


I'm working on a Volume Shadow Copy program. I have just found out that I need to use a different set of .h files (vsbackup.h) and associated .lib files (vssapi.lib) to compile the project for Windows XP (in comparison to Vista and 7). This is due to a series of subtle changes in the .h files: in XP, a call such as CreateVssBackupComponents() was a call into the API (there was only the declaration in vsbackup.h); the more recent vsbackup.h changes this into CreateVssBackupComponents() { CreateVssBackupComponentsInternal(); } and when I compile my project with the newer .h and .lib files and run the program under XP, it says

The procedure entry point "CreateVssBackupComponentsInternal" was not found in DLL "vssapi.dll".

Is there any possibility to incorporate these two different lib files in one project, so that I don't have to compile two different versions of the program?


Solution

  • If you need to work with two different versions of the dll (because if I understood correctly the problem lies there, the different lib/headers are just the tip of the iceberg) you should dynamically load it with LoadLibrary, check the presence of the entrypoints you need with GetProcAddress and call the functions you need with the function pointer that it returned.