- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to be able to dynamically load DLL files, with something like:
character*255: DLL_name_and_path
character*255: DLL_routine_name
and be able to the following: (approximate, from Google searches)
ierr = LoadLibrary(DLL_name_and_path)
iHandle = GetProcAdd(DLLL_routine_name)
How do I then call the routne?
It would be along the lines of
CALL iHandle(Param1, Param2, Param3)
I can find Windows-centric help on the LoadLibrary/GetProcAddr parts, but the final part - how to use within Fortran - has beaten me.
character*255: DLL_name_and_path
character*255: DLL_routine_name
and be able to the following: (approximate, from Google searches)
ierr = LoadLibrary(DLL_name_and_path)
iHandle = GetProcAdd(DLLL_routine_name)
How do I then call the routne?
It would be along the lines of
CALL iHandle(Param1, Param2, Param3)
I can find Windows-centric help on the LoadLibrary/GetProcAddr parts, but the final part - how to use within Fortran - has beaten me.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Omit the two character statements.
Use the kernel32 module, Cray pointers, C strings, and supply an interface:
eg,
use kernel32 !(or whatever has the LoadLibrary, GetProcAddress, FreeLibraryAPI's)
implicit none
interface
subroutine locMyDLLSub(...)
...
end subroutine locMyDLLSub
end interface
integer(4) p
pointer (r,locMyDLLSub)
logical(4) :: res = .false.
p = LoadLibrary('MyDLL.dll'C) !put the DLL in the same folder asits client
r = GetProcAddress(p,'MyDLLSub'C)
call locMyDLLSub(...)
...
res = FreeLibrary(p)
...
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page