Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Dynamically loading a DLL twice

Adrian_F_1
Beginner
806 Views

I have in my Fortran code:

        dll_handle = LoadLibrary('Test123.dll'//char(0))

However this Fortran code may also be called from a C++ wrapper which may have already dynamically loaded this DLL.  From a quick test the Fortran call does not simply return the handle that the C++ wrapper got when it loaded it, but returns a different handle.  Has the DLL been loaded twice?  If so is this a problem?

0 Kudos
2 Replies
Adrian_F_1
Beginner
806 Views

Apologies it does seem to use the same handle.  I was looking at what the C++ variable was pointing to rather than the variable itself which is of HMODULE type which apparently is a pointer of type pvoid (defined as typedef void *PVOID;)

I guess the Fortran variable dll_handle, declared as integer, is also one of these.

0 Kudos
Steven_L_Intel1
Employee
806 Views

Make sure the Fortran variable is declared integer(HANDLE), not just integer.

0 Kudos
Reply