I\'m a bit puzzled as to how Pointers should be properly used in my scenario. I have a DLL with some embedded resources in it. I expose a function in this DLL which passes binar
You don't need to export any functions at all from your DLL. You can just use the DLL's module handle directly from your host executable.
You are already passing a module handle to the resource stream constructor. You are passing the module handle of the executable. Instead, pass the module handle of the library.
var
hMod: HMODULE;
....
hMod := LoadLibrary('ResDLL');
try
S:= TResourceStream.Create(hMod, ...);
....
finally
FreeLibrary(hMod);
end;
If you don't want to call any functions in the DLL, if it is a resource only DLL, then use LoadLibraryEx
and LOAD_LIBRARY_AS_IMAGE_RESOURCE
instead:
hMod := LoadLibraryEx('ResDLL', 0, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
Perhaps you know that the the DLL is already loaded. For example, it is linked to your executable implicitly. In that case you can more simply use GetModuleHandle
rather than LoadLibrary
or LoadLibraryEx
.
hMod := GetModuleHandle('ResDLL');
S:= TResourceStream.Create(hMod, ...);
Note that I omitted all error checking for the sake of a simple exposition.