Emory
Emory

Reputation: 21

C++ - Test if a DLL exists to conditional run certain functions

I have an application that I want to distribute to two sets of customers: 1) a full version that calls functions from a third party library, and 2) a limited version that disables those calls.

I would like to avoid having separate builds and simply distribute the executable to all and include the DLL only for customers that pay for the extra features in the third party library.

However, when I build with the library included, the application will not run if the DLL can't be found.

Is it possible to test if the DLL exists at runtime prior to DLLMAIN being called?

Upvotes: 2

Views: 1432

Answers (1)

Garnik
Garnik

Reputation: 3

You can check it by the following way

LPCWSTR dllName = helper::developer::getDllPath();
HINSTANCE dynamicLib = LoadLibraryW(dllName);

if (dynamicLib)
{

}

Upvotes: 0

Related Questions