C++ how to dynamically load a 3rd party DLL file - c++

I need to integrate a 3rd party DLL file with my application, I have only the .DLL and the .pdf documentation of the DLL.
This is the pdf of the dll: http://www.whiteboxrobotics.com/Support/pdf/PC-BOT_dotNet_v1.0_documentation.pdf
I can load the DLL in Visual Studio just by dragging it into the toolbox, BUT, I would like to know how that is done in coding.
Since I only have the DLL, I guess the only option is dynamic loading, using the LoadLibrary() and GetProcAddress().
But it seems to be such a hassle, and I can't figure out how I would load any of the functions which receive some custom (enum) parameters, e.g. in the .pdf the function SendMessage(...) which takes PCBOTEventArgs.messageType as one of the parameters.
Yet loading the DLL through the design view is so simple and extracts the whole DLL.
Why is that?
Is there something else besides using function pointers and GetProcAddress()?

A dotNET = (Mircosoft) .NET Framework is not the same as a "normal" dll, you can't use GetProcAddress and LoadLibrary with .NET dlls
.Net Dlls are normally packed classes, by dragging the dll into your workspace you just import the dlls scope, see for your self in the object browser
to load a .net dll (Assembly) during runtime, for example for a plugin, look here http://support.microsoft.com/kb/837908

3rd Party integration is done using connectivity of what you want to connect for ex you want to add a service to your website, For installing that particular DLL to your website ,first of all read the documentation and connectivity required and than copy paste the DLL files to your projects.
You can make more clear when you can specify the services which want to opt as 3rd party integration

Related

Problem with DLL which depend on another DLLs

I created GUI in C# as gui.dll and create C++/CLI interop interop.dll for C++ project. That means (*.exe call --> interop.dll and interop.dll call --> gui.dll) I test it with C++ console application which is working wintout any problem, because in the end consoleApp.exe and all dlls are in same folder.
What I did:
interop is c++/cli code with reference to C# dll. I created class and export it for use it inside plugin.vst3. C# dll is dynamicaly linked
inside plugin.vst3 project I includeLibrary for interop project to use class and add interop.lib to Linker. interop.dll is dynamicaly linked
What I want:
Now I want use those dlls (gui.dll and interop.dll) inside c++ project as another "dll" myPlugin.vst3 (audio plugin). For those who don't know, audio plugins are located on different location as program which use it. That means, if audio program load plugin, it is different scenario as my consoleApp.exe call dll on same location.
The Problem:
When I run host program which load my vst3, unfortunately vst3 start search for my dlls from AudioHost.exe view not from vst3 view where is my vst3 file located.
For example, if myPlugin.vst3 is inside D:\VstiPlugins\MyTest\, interop.dll is on D:\VstiPlugins\interop.dll and gui.dll next to C:\ProgramFiles\Reaper\Reaper.exe, my plugin is loaded. All files myPlugin.vst3, interop.dll and gui.dll must be on same location D:\VstiPlugins\MyTest.
The questions:
Simple question is "How to load those dlls from vst3" as I describe it in "What I want" and "The Problem"?
What come to mind as firstly was load plugin with code (like LoadLibrary(...)) instead use *.lib. But all examples and solutions, are for dlls which export only C functions and not as my scenario where I use class. Can be dll loaded from code and use class?
Another idea was DLL redirection with manifest file, but there is no documentation for that scenario or I can't find it. And I am not sure if it will be working.

Is there any way to dynamically export functions from a DLL at runtime?

I have an some existing plugin DLLs written in C++ that export 1-40+ functions depending on exactly what functionality they provide. The host application will test for the existence of the export and if it doesn't exist it will assume that the plugin does not provide that functionality.
I now want to write a shim DLL that sits between the host and a plugin. The host will load the shim assuming it's a regular plugin DLL and the shim will in turn load the actual plugin. The shim DLL must provide the exact same interface as the actual plugin since the presence of an exported function impacts the host's behavior.
I would like to have it so that when the host calls GetProcAddress it will look through the shim DLL into the actual plugin DLL and return a pointer to the function in the plugin DLL. This could either be done when GetProcAddress is called, or when the dll is first loaded by somehow generating exports at load time.
My current thought is to use a hook library to hook calls to GetProcAddress and override them as appropriate, however the preference would be do to something less intrusive to the host process.
The alternative to doing this all dynamically is to do this in our build pipeline. We would look at the plugin dll and get all of the exported symbols, then build a custom shim dll that replicates that interface. It's possible, but it will also probably be quite a bit more work than just doing it at runtime.
Edit Feb. 1, 2014: There's no obviously supported way of doing this and I ran into issues hooking GetProcAddress so I ended up doing this via our build pipeline and forwarded exports.

Move manifest file to dll?

I'm using a third party component in my application that is distributed either as a COM component, or can be referenced using a .manifest file. Either way it is loaded using CoCreateInstance(). The files needed for the third party component reside in a subfolder. The component developer told me to include a .manifest file in the Visual Studio 2010 settings (in the "Manifest" section) of the executable, and loading the component works without problems.
Now I'm using the third party component from a DLL only, to encapsulate the features used from the third party component. I'm loading the DLL dynamically, using LoadLibrary(). Using the component still works, I can use the component from within the DLL that is loaded by the EXE that has the manifest file referenced.
To further separate the EXE from the third pary component, I'd like to move the manifest to the DLL, too, where is the only place the component is used. In this way every new EXE I'd like to write can use the DLL and indirectly use the features. For now, I have to add the mainfest to every new EXE, but I don't want to do that.
Is there a way to move the manifest used by the EXE to a DLL?
You can put the manifest in the DLL, but it may not be activated automatically. You may need to do that manually using the activation context API. I think a lot depends on what the manifest is being used for. I suspect you are trying to use registration free COM, but that's only a guess.
Anyway, these links may well be useful to you:
RT_MANIFEST resource, and ISOLATION_AWARE_ENABLED (Junfeng Zhang)
Isolating Components (MSDN)

C++ windows dll and libxml2 dependency woes

I develop a plug in dll, i.e. some other process loads my dll, C++ using VS...
I need to add xml parsing to my code and I use libxml2.
I have added that do my dll and now when the application tries to load my dll it fails to load. It is a dependency issue but I can not figure out what all other libs/dlls I need to add to my project.
Any ideas?

COM Object DLL Load Issue

I am working on a Qt DLL that is used as a plugin for a large application. This DLL depends on other DLLs that are sadly not located in the same folder and hence will only load if the current working directory has been set correctly (which the large application does prior to calling LoadLibrary on the DLL). I have no control over this behaviour.
I have been asked to add a simple COM object to this plugin which I have done but I now have the problem that the DLL cannot be registered or used by a 3rd-party application unless the current working directory is set correctly - because any LoadLibrary calls on the plugin fail due to the missing dependencies. Obviously I have no control over the current working directory used by 3rd-party apps and at this stage I am not allowed to modify the PATH to ensure the dependencies can be found.
I have tried using /DELAYLOAD for the dependent DLLs but this fails with 'cannot delay-load foo.dll due to import of data symbol...' errors. Again, I cannot easily change the way these dependent DLLs are used.
Currently I think the only solution is to move the COM object into a stand-alone DLL that doesn't depend on anything else but I am under pressure to find a solution and leave the COM object in the plugin DLL. I can't see how this is possible so I thought I'd see if anyone else has any ideas. Some form of system-wide SetDllDirectory call would help or some registry hack that could set the working directory when a 3rd-party app calls LoadLibrary on my plugin.
IMO separating the COM object into a separate .dll is the cleanest solution - anyone would expect an in-proc COM server to be registered by using regsvr32 and that requires no fancy dependencies in that COM server.
I don't know if it's precisely a solution to your problem, but maybe this can help you: try to look at the possibilities offered by manifest files. I hope it will help.
You could use a runtime registration model.
The Dll could register itself as a COM server in its own initialisation code.
This only requires that loadlibrary is guaranteed to be called before the dll is used as a COM server.